cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

can't upload files with curl

Highlighted

can't upload files with curl

New member | Level 2

I am trying to upload files with curl.  Based on community advice I think this should be correct:

 

curl -X POST https://content.dropboxapi.com/2/files/upload \

    --header "Authorization: Bearer MyOauthApiKey" \

    --header "Dropbox-API-Arg: {\"path\": \"/directory/myfile\"}" \

    --header "Content-Type: application/octet-stream" \

    --data-binary @directory/myfile

 

but I get a 404 error.  Going to https://content.dropboxapi.com/2/files/upload in a browser window also resuts in an error.

 

What is the correct way to do this?

1 Accepted Solution

Accepted Solutions
Highlighted

Re: can't upload files with curl

Dropboxer

Yes, /2/files/upload only supports files up to 150 MB. For larger files, use upload sessions.

View solution in original post

7 Replies 7
Highlighted

Re: can't upload files with curl

Dropboxer
That code looks correct, and it's working for me. (Browsing there in a browser isn't supposed to work.)

Is this the exact code you're running? Can you share the full code/output? (Just be sure to redact the access token of course.) You can also add a "-v" flag to tell curl to show verbose output.
Highlighted

Re: can't upload files with curl

New member | Level 2

Intersting, now that I look at the output in more detail I see

 

< HTTP/1.1 413 Request Entity Too Large

 

This is a 2.3GB file.  Should I be uploading this in a different way?

 

Highlighted

Re: can't upload files with curl

Dropboxer

Yes, /2/files/upload only supports files up to 150 MB. For larger files, use upload sessions.

View solution in original post

Highlighted

Re: can't upload files with curl

Explorer | Level 3

Hello,

I would like to to do the following:

1. Use curl to upload a file to dropbox using a Raspberry PI

2. This command

curl -X POST https://content.dropboxapi.com/2/files/upload \ --header "Authorization: Bearer MyOauthApiKey" \

--header "Dropbox-API-Arg: {\"path\": \"/directory/myfile\"}" \

--header "Content-Type: application/octet-stream" \ 

--data-binary @directory/myfile

3. On the dropbox website, I would like to give access to the raspberry pi "MyOAuthAPIKey" , but DO NOT want the raspberry pi to have to complete any steps. Just give the raspberry pi this "Key"   and then use the Curl statement.

Please confirm this will work and the instructions. Otherwise how do I use curl ?

 

Thanks

Highlighted

Re: can't upload files with curl

Dropboxer

@cjh39 In place of "MyOauthApiKey" you would put your Dropbox API OAuth 2 access token.

Once retrieved, Dropbox API OAuth 2 access tokens can be used entirely programmatically, and don't expire automatically, so they can be used without manual user intervention. E.g., you can use it in unattended code, such as on a Raspberry Pi.

You can find information on getting a Dropbox API OAuth 2 access token in the OAuth Guide.

Once you have an access token, the /2/files/upload endpoint is the right way to upload files smaller than 150 MB. 

If you have any further questions or issues, please open a new thread so we can help without spamming anyone else on this old thread.

Highlighted

Re: can't upload files with curl

New member | Level 2

can't upload files through swiftydropbox

CURL - 

curl -v \

-X POST \

-H "Dropbox-Api-Arg: {\"path\": \"/home/Hike/ios_analytics/New.txt\"}" \

-H "Content-Type: application/octet-stream" \

-H "User-Agent: OfficialDropboxSwiftSDKv2/5.0.0" \

-H "Authorization: Bearer <REDACTED>" \

"https://api-content.dropbox.com/2/files/upload"

 

 

Swift code:- 

static func uploadFileFromDropbox() {

        let fileData = "testing data example".data(using: String.Encoding.utf8, allowLossyConversion: false)!

        let client = DropboxClient(accessToken: "<REDACTED>")

        client.files.upload(path: "/home/Hike/ios_analytics/New.txt", input: fileData)

            .response { response, error in

                if let response = response {

                    print(response)

                } else if let error = error {

                    print(error)

                }

            }

            .progress { progressData in

                print(progressData)

        }

    }

 

Highlighted

Re: can't upload files with curl

Dropboxer

@shalutyagi We'll be happy to help with any questions or issues you have with the Dropbox API, but please open a new thread so we can help without spamming anyone else on this old thread.

In your new thread, please share whatever unexpected error/output you get so we can see what's going wrong.

Also, I redacted it from your post, but for the sake of security, you should disable that access token since you shared it publicly. You can disable just this access token using the API:

https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?