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: 

Uploading files by ESP8266 HELP

Uploading files by ESP8266 HELP

lucasromeiro
Explorer | Level 3

Hello!
I'm trying to access Dropbox to save my files in the cloud using an ESP8266, programming in Arduino!
Has anyone ever managed to do this?
I found an HTTP Developer API page.
Maybe with an HTTP POST I get access, save, delete ....
Currently I already do an HTTP POST for my site. The template for my POST is this:

 

POST /drome/parser HTTP/1.1\r\nHost: "+String(host)+"\r\nContent-Type: multipart/form-data; boundary=xxBOUNDARYxx\r\nContent-Length: "258"\r\n\r\n--xxBOUNDARYxx\r\nContent-Type: text/plain\r\nContent-Disposition: form-data; name=\"IMEI\"\r\n\r\n"+macAddress()+"\r\n--xxBOUNDARYxx\r\nContent-Type: application/octet-stream\r\nContent-Disposition: form-data; name=\"file\"; filename=\"envio.txt\"\r\n\r\nTEST\r\n--xxBOUNDARYxx--\r\n\r\n


I could not understand the Dropbox API to do this ...
Can someone help me?
Thank you!

6 Replies 6

Greg-DB
Dropbox Staff
The Dropbox API does offer the ability to upload files programmatically. For example, you can use /2/files/upload:

https://www.dropbox.com/developers/documentation/http/documentation#files-upload

The documentation there has an example of calling that endpoint via curl. We don't have any resources for Arduino/ESP8266 specifically, but you can translate that example/documentation for whatever HTTPS client you're using.

Also, that's a link to the documentation for the HTTPS endpoint itself, but we recommend using one of the official SDKs if possible:

https://www.dropbox.com/developers/documentation

Those have corresponding native methods for the HTTPS endpoints.

lucasromeiro
Explorer | Level 3

Hello can you help me?
it's just an example of how the POST format I'm sending.
then I do not adapt to the dropbox.
above I showed a POST that did not do my project.
Please help me !!!

lucasromeiro
Explorer | Level 3

I'm sending this way:

 

POST /2/auth/token/from_oauth1 HTTP/1.1
Host: api.dropboxapi.com
Content-Type: application/x-www-form-urlencoded
Content-Length: xx
curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \
    --header "Authorization: Basic <MY CODE>" \
    --header "Content-Type: application/json" \
    --data "{\"oauth1_token\": \"qievr8hamyg6ndck\",\"oauth1_token_secret\": \"qomoftv0472git7\"}"

 

 

 

but I get this:

 

HTTP/1.1 400 Bad Request
Server: nginx
Date: Mon, 23 Apr 2018 04:04:30 GMT
Content-Type: text/html
Content-Length: 264
Connection: close
X-Frame-Options: DENY
Content-Security-Policy: sandbox; frame-ancestors 'none'
X-Content-Type-Options: nosniff
Content-Disposition: attachment; filename='error'

 


can you help me ???
I can not make progress.
thank you!

Greg-DB
Dropbox Staff
From the sample you provided, I see that you're trying to call /2/auth/token/from_oauth1, but are just using the oauth1_token and oauth1_token_secret values from the documentation itself. This endpoint is only meant for use if you already have pre-existing OAuth 1 access tokens, which you would plug in there instead of the sample values from the documentation. If you are only starting development now, you would not have OAuth 1 access tokens and so should not be using this endpoint.

If you don't have pre-existing OAuth 1 access tokens, you should send the user through the normal OAuth 2 app authorization flow. You can find information on how that works in the OAuth guide here:

https://www.dropbox.com/developers/reference/oauth-guide

The documentation for the OAuth 2 app authorization flow can be found here:

https://www.dropbox.com/developers/documentation/http/documentation#authorization

lucasromeiro
Explorer | Level 3

Hello Greg!
Thanks for the answer!
I have already registered the application and have token, app key and app secret.
I already used it in the model I posted above. But nothing changes ...

To solve my problem, I would like your help.
Can you send me 2 complete POST examples (what will the server receive, all the characters) ??
- An example for authentication.
- Another example, to send a file or to list the existing files or folders.

With these 2 examples I can modify and create a library for Arduino!

But I need the FULL information. The whole structure of POST done. (what the server will receive)
Because in Arduino we have to do everything at hand ... I need to know all the characters sent, understand?

Kindly help me ... These 2 examples will help me a lot and other people too!

 

Sorry to ask you that. I hope you can help me.

Greg-DB
Dropbox Staff

If you need to see what the actual HTTP requests would look like, I recommend running the curl examples included in the documentation for each relevant endpoint, e.g.,:

 

You can add the "--verbose" flag to the curl command to see the actual request.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    lucasromeiro Explorer | Level 3
What do Dropbox user levels mean?