Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi All,
I'm new to Dropbox API and I'm trying to upload image files from our website to dropbox using api. I'm using FETCH to POST data to dropbox and the file is uploading.However, the image is not getting loaded in dropbox. Below is code that I use:
fetch('https://content.dropboxapi.com/2/files/upload', { method: 'post', body: file1, //Base64 headers: {'Authorization': 'Bearer '+MY_TOKEN, 'Content-Type': 'application/octet-stream', 'Accept': 'application/json', 'Dropbox-API-Arg': '{"path": "/test1/test.jpg","mode": "add","autorename": false,"mute": false,"strict_conflict": false}' } }).then(function(response) { console.log(response.json()); });
Please help me out with this issue. Thank you
Can you clarify what you mean when you say "the image is not getting loaded in dropbox"? What are you seeing or not seeing exactly?
Also, can you share the response you get from /2/files/upload? If the call was successful, it should either contain the metadata of the uploaded file, or if it wasn't successful, an error indicating why.
Hi Greg,
after the upload action I could see the data which i'm sending to dropbox in base64 format, but instead of seeing the image I see the data which i send.
I tried different methods and for 1 option I was successful which was sending the file object which I get from <input type="file"> value. I understand that there's no need to convert the file to base64
Thanks for following up. I'm glad to hear you got this working as desired.
Yes, that's correct, there's no need to apply an additional encoding. Dropbox will accept whatever data you upload exactly as you upload it. So, if you want to upload an image that can be viewed later, you should just upload the unmodified raw data.
i am getting this as response
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input as JSON
@khan_sikki I see you also requested help for this issue in your support ticket and included more information there, so we'll follow up with you there shortly.
Hi there!
If you need more help you can view your support options (expected response time for a 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!