Error: File size too large. Maximum is 10485760. Node.js SDK
I'am using Node.js SDK to upload image. I tried to upload it as a Buffer and as a Readable Stream:
1. As a Buffer:
const uploadWritableStream = cloudinary
.v2
.uploader
.upload_stream(/* some options */);
uploadWritableStream.end(fileBuffer);
2. As a Readable Stream:
const uploadWritableStream = cloudinary
.v2
.uploader
.upload_stream(/* some options */);
fileStream.pipe(uploadWritableStream);
Real file size is 3.9 Mb. I also checked byte length of the buffer before uploading and it's less than 10485760. What am I doing wrong? Also I saw the same issue for django sdk: https://github.com/klis87/django-cloudinary-storage/issues/14
-
Hi,
Can you try this:var cloudinary = require('cloudinary').v2;
var fs = require('fs');
var stream = cloudinary.uploader.upload_stream(function(error, result){console.log(result, error)});
var file_reader = fs.createReadStream('<path_to_file>').pipe(stream);1 -
Hi Daniel,
Thanks a lot! It works without options. My mistake was that I used { format: 'png' } option. But I uploaded file with jpg format and the file size increased after conversion.0 -
Hi @Freddy,
Great to hear it's working. If you need anything else, let us know.0
Post is closed for comments.
Comments
3 comments