We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
lucasromeiro
8 years agoExplorer | Level 3
Uploading files by ESP8266 HELP
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
- Greg-DB8 years ago
Dropbox Community Moderator
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. - lucasromeiro8 years agoExplorer | 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 !!! - lucasromeiro8 years agoExplorer | 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-DB8 years ago
Dropbox Community Moderator
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 - lucasromeiro8 years agoExplorer | 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-DB8 years ago
Dropbox Community Moderator
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.,:
- https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token
- https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
- https://www.dropbox.com/developers/documentation/http/documentation#files-upload
You can add the "--verbose" flag to the curl command to see the actual request.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!