cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Data URL via a JSON POST to a Temporary Upload Link - Composition Help

Data URL via a JSON POST to a Temporary Upload Link - Composition Help

eliotcole
Explorer | Level 4

Hi

 

I just need a little bump in the right direct to upload a file to an approved Temporary Upload Link.

 

I've created the link, and I have the source file in application/octet-stream format, ready and waiting behind a URL.

 

How do I POST that URL to the DropBox API via JSON?

 

The documentation details this for cURL in order to POST data to the URL:

 

curl -X POST https://content.dropboxapi.com/apitul/1/OBFUSCATED
--header "Content-Type: application/octet-stream"
--data-binary @local_file.txt

However, for starters, this is a JSON example we're working with here. Also, I can't find a way to resemble that "data-binary" part into a JSON message where all I have is an octect-stream URL that does not finish with a neat "filename.ext" ending.

 

EDIT - Forgot to mention that I've tried using the save_url method, same results (error below). I'm using Temporary Upload so that it can reliably ensure that an upload slot is available for the file. For the purposes of getting this done, let's assume that the file is 20-30MB. Anyway, when save_url failed, it failed with this message:

 

{
  ".tag": "failed",
  "failed": {
    ".tag": "invalid_url"
  }
}

 

Cheers

Eliot

 

Relevant links:
get_temporary_upload_link - Docs

1 Reply 1

Greg-DB
Dropbox Staff

When uploading to a "/apitul" link like this, the file data to upload needs to be sent in the HTTPS request body as "application/octet-stream". Exactly how you do that will depend on your scenario and the client you're using (curl, in this case).

 

For example, with curl, you can use curl's "--data-binary" parameter to supply the data to send, with the "@filename" syntax to specify a local file. 

 

You mentioned that you just have a URL to the file though, as opposed to having it on the local filesystem, so you probably can't use that parameter exactly like that. You'll need to work out how to get the contents of the data at that URL into the request body. That would be more of a question for using curl itself though, so I can't offer too much support for that, as that's not made by Dropbox. The lack of a name and extension on the source URL itself wouldn't matter though, as the destination path is set by the initial call to /2/files/get_temporary_upload_link anyway.

 

And regarding using the URL directly with /2/files/save_url, are you referring to using large URL that starts with "data:" specifically? That wouldn't be officially supported unfortunately. Otherwise, please share a sample and I'll be happy to look into why it's failing.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?