I'm attempting to upload files from the browser to a Dropbox folder on the user's account. The way I have it set up right now, OAuth2 is triggered using a link, which then redirects to the server when done and the server saves the token with the user's data in the database. That token is then sent back to the user whenever they're on the uploading page. When a file is uploaded, I'm trying to PUT it to the /files_put endpoint using JQuery's AJAX method. The problem I'm having is that whenever I try to upload the file I get an error stating
I'm not entirely sure what to do from here. It would probably work if I were to have the file sent to my server and then out to Dropbox, but I want to avoid that, as that would be slow and would count as double data transfer in and out of my server. With a little bit of research, it would seem that the Access-Control-Allow-Origin header needs to be set on Dropbox's end.
I think the issue with your existing code is the "contentLength" header you're setting. Dropbox's CORS setup doesn't allow that header. It's also non-standard... I think you meant Content-Length , but I don't believe you'll be allowed to set that manually. Just pass the data you want to send and leave off this header.
At least in Chrome, something very similar to your code snippet worked for me once I removed the "contentLength " header.
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?