Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
lucasblue7
8 years agoExplorer | Level 3
fileBinary thumbnail in Node, passed to Browser, cannot display in any format.
The Scenario: We have a Nodejs app that uses the dropbox javascript SDK. On the front end, we have Web and iOS clients that talk to our Node app and ask it for file listings. That much works. We get our results.
The problem: Thumbnails.
In node, I get a fileBinary by calling:
filesGetThumbnail ({path: <mypath>, size: {'.tag': 'w64h64'}}))
I serve this thumbnail to our front end, per recommendations:
Buffer.from(fileBinary).toString('base64')
I've also tried many other variations, such as
Buffer.from(fileBinary, 'binary').toString ('base64')
// as well as 'utf8', 'latin1', new Buffer() instead, etc
I've verified that our client receives the thumbnail just as Node sends it. So far so good.
But I cannot get the image to display.
I've tried a dozen variations in our React client, such as:
<img src={"data:image/jpeg;base64," +imageData} /><img src={"data:image/jpeg;charset=binary;base64," +imageData} />
// also more charsets, a space, atob(), several stackoverflow solutions,...
But 100% of all combinations of encodings and charsets result in broken images.
I've noticed that there are essentially 2 types encoded formats I can produce and send to the browser:
#1 looks like "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAYEBQYFB etc.
#2 looks like "77+977+977+977+9ABBKRklGAAEBAAABAAEAAO+" etc
Looking online, This decoder prefers the second format, while this encoder produces the first format.
But either way, in either format, none of these display, all appear broken.
Can someone please advise?
Thanks,
Lucas
- What version of the JavaScript SDK are you using? There was a binary formatting issue in v3.x, fixed in v4. Please upgrade to v4 if you aren't using that already and let me know if that doesn't help.
2 Replies
- Greg-DB8 years ago
Dropbox Community Moderator
What version of the JavaScript SDK are you using? There was a binary formatting issue in v3.x, fixed in v4. Please upgrade to v4 if you aren't using that already and let me know if that doesn't help. - lucasblue78 years agoExplorer | Level 3
Hi Greg, I just installed the latest version, per your docs, only 3 days ago. v4.0.0 must have been just released.
I installed v4 and thumbs work fine now. I wish the issue had been documented. Thanks, Lucas
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!