Problem uploading files, Timeout and Callback is not a function

SpeechDev
SpeechDev Member Posts: 1
edited January 6 in Developer APIs

Hello Everyone,

I've been using Cloudinary for some times now, and up until yesterday everything was perfectly smooth and running.

However this morning i tried to upload an image ( working on loading state) and i've seen that it wasn't working anymore.

At first i had a 499 Error timeout, and after looking on internet i've found how to increase the client side timeout, which i did but now i got an error from


cloudinary/utils saying :

Callback(result.error) is not a function

And im not really sure on how i could fix that, internet don't give much more help.

i've send an email to the support already but if someone could help me find a solution here that would be cool :)


Thanks !

Answers

  • DannyFromCloudinary
    DannyFromCloudinary Member, Cloudinary Staff Posts: 80
    edited January 6

    Hey, I actually replied to your ticket earlier, but wanted to post my response here in case it helps anyone else out.

    The final parameter expected is indeed a callback function, which from your screenshot, doesn't appear to be what you're passing to the upload method. You could use something like

    cloudinary.v2.uploader.upload("assets/sample.jpg", { public_id: "my-image" },
      function(error, result){
        if (error) {console.log(error)}
        else {console.log(result)}
      }
    );
    

    We also support, and actually recommend, using Promises, which you can do like so:

    cloudinary.v2.uploader.upload("assets/sample.jpg", { public_id: "my-image" })
      .then(result=>console.log(result))
      .catch(error=>console.warn(error));