You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

annahernandez99's avatar
annahernandez99
Explorer | Level 4
4 years ago

Excel files uploaded to Dropbox using Node.js SDK are invalid

I am trying to upload Excel files to Dropbox using the Node.js SDK (https://github.com/dropbox/dropbox-sdk-js). The files are received from JsReport, and are saved correctly when saved to my local disk. However, when uploading to Dropbox, the files end up long strings instead of Excel files.

The body in this case is a string that gets encoded to base64. The filename is speedtest_daily_2021-01-15_test26.xlsx.

This line writes the file successfully to my local drive:

fs.writeFileSync(*filename*, body, {encoding: 'base64'});
This is the code I'm using to upload the file to Dropbox:

body = Buffer.from(body).toString('base64');

dbx.filesUpload({ contents: body, path: saveLocation + `/` + filename })
.then((response: any) => {
console.log(`Saved file "${filename}" to Dropbox folder ${saveLocation}`);
}).catch((uploadErr: DropboxError<files.UploadError>) => {
console.log(uploadErr);
});
This is how the Excel file should look, and looks on my local:

This is what happens when I open the Dropbox Excel file:

This is how the Dropbox file looks when I open it up in a text editor:

I've tried various encoding combinations for Dropbox but none of them seem to work. tell me what i should do

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,915 PostsLatest Activity: 5 hours ago
333 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!