Getting "Empty file" error when file is full?

Comments

7 comments

  • Avatar
    Stephen Doyle

    Hi Thomas,

    May I please check, are you logging the details (in particular, the size) of the file on the server before sending it to our SDK? 

    I don't just mean the value of 'file.tempFilePath' or 'files' but can you also check if the file exists on the disk and is non-empty?

    Most likely, the error means that what was sent to our server was an empty file, but I can't see where in your code that could be happening. Is it possible the 'files' are being duplicated somehow, and the second request is sending two files in req.files, causing req.files.image to be empty, or something like that?

    0
    Comment actions Permalink
  • Avatar
    Matt West

    I am having this EXACT same problem. First upload works, next one and all subsequent ones get the empty file error, until I restart my express app. I'm using the same few files for testing, so I know they can all upload correctly. 

    0
    Comment actions Permalink
  • Avatar
    Stephen Doyle

    Hi Matt,

    May I please ask for some more information about the exact calls you're making and any debugging steps you've taken?
    If you have a small standalone project that demonstrates the issue that would be perfect, but some info I can use to create the same setup would be helpful, too.

    Thanks,

    Stephen

    0
    Comment actions Permalink
  • Avatar
    Matt West

    Hi Stephen,

    Thanks for your response. My code is very similar to Thomas's but I can post it later today. I think we're following the same examples, though. 

    I don't have a standalone project, but I do a simple function responsible for the upload and I know the exact line I get the error on if that helps. I also know how to recreate the bug, much as Thomas describes above. I just don't know why the problem is occurring. 

     

    0
    Comment actions Permalink
  • Avatar
    Stephen Doyle

    Hi Matt - Thanks, the full example would be helpful, or if you're working from a tutorial or other sample, a link to that

    Thomas' example doesn't look like one of the sample apps distributed with our SDK, so I'm not sure how best to try and reproduce what's happening here - The upload() method in our SDK should be fine, and the most likely reason for an empty file error is that an empty file was passed to it, but I can't see why that might be in Thomas' example 

    0
    Comment actions Permalink
  • Avatar
    Ben

    Hi guys - I'm a bit late to the party, but thought I'd share what I learned. I was getting the same error as Thomas. I discovered that the issue is with `express-fileupload` and not with Cloudinary's `cloudinary.uploader.upload` function. I substituted `express-fileupload` with `multer` as per this blog https://code.tutsplus.com/tutorials/file-upload-with-multer-in-node--cms-32088 and I can no longer reproduce the error.

    I hope it helps

    Happy coding

    1
    Comment actions Permalink
  • Avatar
    Aleksandar Kostadinov

    Hi Ben,

    Thank you for sharing. Hopefully, this will help rule out/narrow down such issues if anyone else experiences them in future.

    Best regards,

    Aleksandar

    0
    Comment actions Permalink

Please sign in to leave a comment.