How to Resolve "PDF Files Can’t Be Shared Externally" in Cloudinary
If you’re using Cloudinary to upload and share PDF files, you may have run into the annoying error: "PDF files can’t be shared externally." This can be particularly frustrating when you’ve uploaded a PDF and expect to share it publicly, but Cloudinary blocks access by default.
In this post, I’ll walk you through why this happens and how to resolve it step-by-step, so you can successfully share PDF files externally without any hiccups.
Why Does This Happen?
Cloudinary, by default, restricts the delivery of certain file types (like PDFs and ZIP files) for security reasons. This means even if you upload a PDF and get a URL, it won’t be accessible unless you explicitly allow PDF file delivery in your Cloudinary settings. Additionally, the file must be marked as public for it to be accessible via its URL.
Let’s dive into the solution.
Step-by-Step Solution
1. Enable PDF File Delivery in Cloudinary
First, let’s make sure that Cloudinary is set to allow PDF file delivery:
Log in to Cloudinary
Go to Cloudinary and log in to your account.Go to Security Settings
Click on the Settings icon (gear icon) located at the top-right corner of the Cloudinary dashboard.Scroll to the Security Section
Scroll down until you find the Security section.Allow PDF and ZIP File Delivery
Look for the option labeled PDF and ZIP files delivery. Toggle the switch to Allow delivery of PDF and ZIP files.Click Save
After enabling the setting, be sure to click Save to apply the changes.
This will allow Cloudinary to serve PDF files from URLs.
2. Ensure the File is Public
Even after enabling PDF delivery, your file needs to be marked as public to be accessible.
Check the File in Cloudinary Dashboard
Go to the Media Library in your Cloudinary dashboard.
Find the PDF file you uploaded (e.g.,
resumes/nxx0wzdvdsonnuxgenif.pdf
).Ensure the File is Public
Confirm that the file is set to Public. If it’s not, you won’t be able to access it through its URL.
Update the Access Mode During Upload
If you’re uploading the file programmatically, you need to ensure that it’s set as public. For example, when uploading a file via JavaScript, add the access_mode: "public"
parameter:
javascript
const cloudResponse = await cloudinary.uploader.upload(fileUri.content, {
resource_type: "raw", // Treat PDF as a raw file
access_mode: "public", // Make the file publicly accessible
folder: "resumes",
});
#### **Conclusion**
The "PDF files can’t be shared externally" error on Cloudinary is a common but easily solvable issue. By enabling PDF file delivery in your Cloudinary settings and ensuring your files are marked as public, you can quickly resolve this problem. If you’re still facing issues, double-check your frontend code and consider using an embedded PDF viewer.
I hope this guide saves you the two days I spent debugging this issue. Happy coding! 🚀
Top comments (0)