简体   繁体   中英

Cloudinary image size is 10 mb but unable to upload images of even 500 kb using node.js

const myCloud = await cloudinary.v2.uploader.upload((req.body.avatar||req.body.avtar), {
        folder: "avatars",
        width: 150,
        crop: "scale",
        limit: 5000000,
        maxFileSize: 500000,
      function(err) {
            console.log(err)
        } 

Iam unable to upload images which are greater in size like having size more than 100 kb can anyone tell me what am I doing wrong? Uploading images greater than this size results in status code 500 and xhr.js:10 line is shown always.

I'm Danny, one of the Developer Support Engineers over at Cloudinary.

I've taken a look at some of your upload requests in our logs and in each case the file is empty, so it seems that req.body.avatar and req.body.avtar aren't populated with any data. Could you please check that they have content (base64 encoded image, reference to local file, or a URL) before they reach the uploader? You may need to use a middleware such as Multer in order to pass form data to the uploader.

I'm happy to help you here, but if you'd prefer to keep code snippets private, you're welcome to raise a ticket in our support center and we can reply there.

Looking forward to hearing back from you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM