2025 sparked some incredible conversations across our community 👩💻. Discover the highlights and see what’s ahead in 2026.
Forum Discussion
JagsDew
5 years agoExplorer | Level 3
Problem uploading converted image file(.dng) into dropbox
I have an application in node js in which I am uploading the image to the node server after that I compress the file to reduce the size. After that, I upload it to dropbox but the uploaded file has ...
Greg-DB
Dropbox Community Moderator
5 years ago[Cross-linking for reference: https://stackoverflow.com/questions/65039727/problem-uploading-converted-image-file-dng-into-dropbox ]
When uploading a file to Dropbox via the filesUpload method in the official Dropbox API v2 JavaScript SDK, you need to pass in the file data to upload as the "contents" parameter in the FilesCommitInfo.
In your code, I see you're passing in the 'file.data' variable, but this apparently does not contain any data and so your uploaded file is empty. I see you're calling fs.readdir to get the list of files in the folder, but that does not actually give you the file data for each file. It just gives you the file name. You'll need to instead get the file data from the local filesystem and pass it to the filesUpload method, e.g., perhaps using the fs.readFile method.
- JagsDew5 years agoExplorer | Level 3Thank you for your solution. I tried this code with changes but this time even the image file is not uploaded to dropbox. Please find my updated code below.
var namefile= path.basename("C:\\Users\\uploads\\converted\\"+foldername+"\\"+req.file.originalname,".ARW" ); var image =namefile+".dng"; fs.readFile("C:\\Users\\uploads\\converted\\"+foldername+"\\"+image, function(err, data) { var dbx = new Dropbox({ accessToken: 'XXXX' }); dbx.filesUpload({path: '/'+link+'/'+image, contents: data}) .then(function(response) { console.log(response); }) .catch(function(error) { console.error(error); }); });I appreciate your help.- Greg-DB5 years ago
Dropbox Community Moderator
Have you checked what the value of your 'data' variable is? Does it contain the expected file contents?
I notice you aren't checking the 'err' variable for the readFile call, so you may not be catching any errors that are occurring when reading the file. You should update your code to check that.
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!