Uploading issue using cloudinary.uploader.upload

sephiroth
sephiroth Member Posts: 2
edited March 2023 in Developer APIs

I am using cloudinary in my node.js express server. When i use the line "const result = await cloudinary.uploader.upload(`path`);"  i get the correct response the first time i run the code in my server. When i try and make another request to my server i get the following error "{ message: 'Empty file', name: 'Error', http_code: 400 }". If i restart my server everything works fine but the first time i run the code but after that i get the error again. Does anyone know a solution for this?

Tagged:

Answers

  • Ranson
    Ranson Cloudinary Staff Posts: 24

    Hi there,


    That error message generally means that Cloudinary received an empty request not containing a file. Would you please send an example of your code anywhere so we can take a look?

    Just to double-check, is the await being called from within an async function?

  • sephiroth
    sephiroth Member Posts: 2

    yes it is and i sent you the code already it was only that single line that is relevant to cloudinary anyway. Like i said that line of code executes the first time, then subsequent times it does not until i restart the server.

  • Ranson
    Ranson Cloudinary Staff Posts: 24

    Since the root issue isn't specifically related to the Cloudinary upload code you shared, the rest of the code would help us figure out exactly what is going on.

    That being said, it sounds like the async event was not set up correctly or there's something related to the file not being appended to the upload call on the second request. I would suggest throwing some logs up to see what is being passed into the upload on the second request and investigating the setup for the async/await.