0

I am working on a chrome extension wherein the users can store the files in their dropbox account. As mentioned in the dropbox api share file link, I used that endpoint to generate a file sharing link which generates a compressed/shortened sharing url like https://db.tt/c0mFuu1Y. Now my query is that how can I use the dropbox api to get the contents of the file using this shared link, somewhat like what happens here for the files owned by the user.

bawejakunal
  • 1,678
  • 2
  • 25
  • 54

1 Answers1

0

See https://www.dropbox.com/help/201.

If you have a shortened link, like the example you gave, you'll want to fetch that first and get the Location header on the 302 response. That will give you the full (non-shortened) share link. From there, you can apply the technique described in the link above... add the ?raw=1 query parameter and just download the contents.

user94559
  • 59,196
  • 6
  • 103
  • 103
  • any idea on how to capture a 302 status in jquery ajax or xmlhttprequest ? I looked up a lot but couldn't find any solution on how to grab that status and location header, although I can see it under `Network` tab in browser console that the ajax request to compressed url returns with a 302 status. – bawejakunal Jul 30 '15 at 08:04
  • I suspect that you can't do this. See http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call. I'd recommend doing this part on the server (assuming you have a server somewhere). – user94559 Jul 30 '15 at 14:51
  • I found the solution within the dropbox api itself, to get the non-shortened url we have to pass the query parameter `short_url=false` and that directly sends over the target url which can then be used to apply the `raw=1` fix to get the contents directly. – bawejakunal Jul 31 '15 at 05:50