I keep getting this error { message: 'Empty file', http_code: 400 }
Please help , I keep getting this error. some photos upload and some don't.
Why is this ?
The files are there but are not uploading and cant find any solutions anywhere.
-
Hi John,
In most cases, if you receive that error it means the upload API was called with an empty file, either because the file you wanted to upload wasn't sent in your API call, or you provided an HTTP/HTTPS URL of an image for us to request, but we received no response when we tried to load it for you.
For the API calls which receive that error, are you able to verify that the file you tried to upload was indeed sent in the API call?
Are you able to share an example of your code, or an example showing the parameters you sent and the response to the call?
If you can share your account's cloud name I can check our logs also and see if there's any additional information available.
Thanks,
Stephen0 -
Hello Stephen , this is my code below i am also using express-fileupload to handle the files.
const cloudinary = require('cloudinary').v2;
cloudinary.config({////////});
// Check File Type
module.exports = function(app) {
app.post('/uploadphoto', function (req, res) {const file=req.files.file;console.log(file);const file = req.files.file;
cloudinary.uploader.upload(file.tempFilePath,function(error, result) {console.log('error',error);console.log('result',result);res.send({success:true,result});});
});
}This is what the file obj looks like when i console.log it.{ name: '4900426-256.png', data: <Buffer >, size: 2381, encoding: '7bit', tempFilePath: '/tmp/tmp-2-1572462942863', truncated: false, mimetype: 'image/png', md5: '0465584404e424ac564de1a3a3f509a2', mv: [Function: mv] }
0 -
Hi John,
Are you working from a tutorial or sample application? If so, was it written before express-fileupload 4.0 was released? Can you share a link, please?
I've been checking online and `express-fileupload` 4.0 changed how multipart form data is parsed and the files processed, which could explain why when you try to use the file, it's empty, but it appears correctly in req.files
Here's an example of one of the questions I found: https://stackoverflow.com/q/23114374/21062
(That may not explain your exact issue, but it covers a different case where the version of that module affects how files are uploaded and made usable)
Thanks,
Stephen
0
Post is closed for comments.
Comments
3 comments