We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

squidlauncher64's avatar
squidlauncher64
Explorer | Level 3
2 years ago

downloading an image using dropbox API

Hello,   I am trying to download an image from dropbox api in react native. I am getting a success code: '200' and the response says that it is ok. I have included some of the javascript code below...
  • Здравко's avatar
    Здравко
    2 years ago

    Hi squidlauncher64,

    You didn't account that 'blob' method doesn't return actual blob, but Promise object wrapping this blob! That's where all your troubles come from. Also when you try to stringify some object, you're getting object declaration (no actual data) and that's why appear so short result - "[object Object]" - i.e. one more mess. 🙂

    You have to handle correct type in correct way. A simplistic example follows:

    var reader = new FileReader();
    await fetch(...all staff here...).then((r)=>r.blob()).then((b)=>reader.readAsDataURL(b));
    var b64encoded = reader.result;
    var rawBase64 = b64encoded.slice(b64encoded.search(',')+1);

    Depending on what you need either full encoded result (b64encoded) can be used or only the actual/raw base64 encoded string part (rawBase64). 😉

    Hope this helps.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 12 months ago
325 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!