Reputation: 85
I was wondering if there's a way to upload a .doc, .pdf, or .zip file to cloudinary. I got the data from the client using multer and i recieve something like this, for example:
fieldname: 'file',
originalname: 'F12se.zip',
encoding: '7bit',
mimetype: 'application/x-zip-compressed',
buffer: <Buffer 50 4b 03 04 14 00 00 00 08 00 90 68 aa 50 ad bd d9 53 13 05 00 00 c5 0a 00 00 0d 00 00 00 43 68 61 6e 67 65 6c 6f 67 2e 74 78 74 9d 56 eb aa d3 40 10 ... 1864943 more bytes>,
size: 1864993
I guess I have to do something with the buffer, but I'm not sure as to what or how.
Any help would be appreciated. Thanks.
Upvotes: 0
Views: 1487
Reputation: 56
Are you on the free or paid version of Cloudinary? Looking at your code everything seems to be ok.
Please note that PDFs and some archive formats such as zip, rar and tagz are, by default, blocked for delivery for FREE accounts in order to reduce the chances of malware or other potentially harmful files being distributed via the Cloudinary domain. Here's a link for refference
Upvotes: 0
Reputation: 151
I work on Cloudinary's Customer Success team, and while we don't have any example code with multer uploads, if you save the contents of the buffer as a file, you can then upload it to Cloudinary as a raw resource_type with
cloudinary.v2.uploader.upload("filename.ext",
{ resource_type: "raw" },
function(error, result) {console.log(result, error); });
as per https://cloudinary.com/documentation/upload_images#uploading_non_media_files_as_raw_files
If you need further assistance, you're welcome to raise a ticket via our Support Center over at https://support.cloudinary.com/hc/en-us/requests/new
Upvotes: 1