We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
SephDragoon
10 years agoExplorer | Level 4
Dropbox API v2 for Second Life
Update (01/14/2019): Finally back to trying to use this code. A resolution was seemingly made, but not fully implemented. I am able to access the API now, but I still cannot use file/download. I have...
Greg-DB
Dropbox Community Moderator
7 years agoI just tried this, and the new supported content types are working for me. Here are a few sample calls:
$ curl -X POST https://content.dropboxapi.com/2/files/download \
> --header "Authorization: Bearer <ACCESS_TOKEN>" \
> --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}"
This is the test file data.
$ curl -X POST https://content.dropboxapi.com/2/files/download \
> --header "Authorization: Bearer <ACCESS_TOKEN>" \
> --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}" \
> --header ""
This is the test file data.
$ curl -X POST https://content.dropboxapi.com/2/files/download \
> --header "Authorization: Bearer <ACCESS_TOKEN>" \
> --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}" \
> --header "Content-Type: application/octet-stream"
This is the test file data.
$ curl -X POST https://content.dropboxapi.com/2/files/download \
> --header "Authorization: Bearer <ACCESS_TOKEN>" \
> --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}" \
> --header "Content-Type: text/plain"
This is the test file data.
$ # using the verbose option for more detail:
$ curl -vX POST https://content.dropboxapi.com/2/files/download \
> --header "Authorization: Bearer <ACCESS_TOKEN>" \
> --header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}" \
> --header "Content-Type: text/plain; charset=utf-8"
> POST /2/files/download HTTP/1.1
> Host: content.dropboxapi.com
> User-Agent: curl/7.54.0
> Accept: */*
> Authorization: Bearer <ACCESS_TOKEN>
> Dropbox-API-Arg: {"path": "/test.txt"}
> Content-Type: text/plain; charset=utf-8
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 15 Jan 2019 16:25:48 GMT
< Content-Type: application/octet-stream
< Content-Length: 27
< Connection: keep-alive
< accept-ranges: bytes
< etag: W/"73c1c021eccc7"
< pragma: no-cache
< cache-control: no-cache
< original-content-length: 27
< dropbox-api-result: {"name": "test.txt", "path_lower": "/test.txt", "path_display": "/test.txt", "id": "id:25N5ksooX-sAAAAAAAKn0Q", "client_modified": "2019-01-15T16:24:48Z", "server_modified": "2019-01-15T16:24:49Z", "rev": "73c1c021eccc7", "size": 27, "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"}
< X-Server-Response-Time: 1984
< X-Dropbox-Request-Id: c87ab76814c43ef58c5d284e646fdec7
< X-Robots-Tag: noindex, nofollow, noimageindex
<
* Connection #0 to host content.dropboxapi.com left intact
This is the test file data.
While you can now specify any of those three newly supported Content-Type values (or none) for the request, the response's Content-Type for /2/files/download is not guaranteed to be the same as that of the request; it is always "application/octet-stream" to indicate that it is returning the binary data for the requested file (assuming the call succeeded).
I'm not familiar with your platform, but from the SecondLife documentation you quoted it sounds like the issue now is that "LL server" isn't accepting the the "application/octet-stream" response Content-Type for the response from Dropbox for the /2/files/download call.
OzLinden
7 years agoExplorer | Level 3
I suggest retrying your POST test with an
Accept: text/plain
header
- SephDragoon7 years agoExplorer | Level 4That I will try as soon as I get home, thank you.
- Greg-DB7 years ago
Dropbox Community Moderator
I recommend looking into getting the LL server updated to accept the "application/octet-stream" Content-Type, as it looks like that's where the current rejection is taking place.
I'll be happy to pass along a request to change something on the Dropbox side too, but I should reiterate I can't guarantee such a change would be implemented. Can you specify exactly what change(s) would be necessary though?
Also, I just checked and unfortunately specifying an "Accept" request header like OzLinden suggested won't change the result in this case.
- SephDragoon7 years agoExplorer | Level 4Well, there goes that. If some solution like what he suggested could be made though, it would help. Otherwise a way to get plain text responses would be lovely. I can understand if that won't work for most file types, but plain .txt files shouldn't be a problem.
- Greg-DB7 years ago
Dropbox Community Moderator
Ok, thanks! I've sent that feature request along. I'll follow up here with any updates on that, but at the moment I'm not aware of any such planned update.
- OzLinden7 years agoExplorer | Level 3
I'm afraid that there's no way for us to modify Second Life to allow anything but a text-based content type.
I'm not clear on how to test the Dropbox API... is it true that if I upload something as text/plain I can only get it back as application/octet-stream? That doesn't seem very useful...
- SephDragoon7 years agoExplorer | Level 4It works very well for what it is. It had been my go to method of data storage from second life for a long time. The main advantage is that unlike a php to sql method, you do not need to use an intermediary server. The downside is that all logic then has to be put into the LSL script. I may have found a method to make it work for now, but it is a hack using the get_temporary_link call.
- Greg-DB7 years ago
Dropbox Community Moderator
OzLinden If you want to test the Dropbox API, I have a few examples in this comment from earlier in the thread that show use of the /2/files/download endpoint. The API v2 Explorer can be useful for testing/prototyping calls like this.
In any case, the /2/files/download endpoint does return "application/octet-stream" as the response's Content-Type for any type of file.
SephDragoon I'm glad to hear you may have found a workaround!
- SephDragoon7 years agoExplorer | Level 4I would not consider it a solution, but I am able to get the data back out. Since upload works as is, I can still use drop box, but I will be relying less heavily on it. A two step process for every data lookup isn't ideal.
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!