Giter Club home page Giter Club logo

dropbox-sdk-go-unofficial's People

Contributors

aaronstaley avatar arran4 avatar davidjwilkins avatar dependabot[bot] avatar dexterhaslem avatar diwakergupta avatar gwatts avatar joncalhoun avatar justinkao avatar karandeep-johar avatar koogoro avatar ncw avatar rajatgoel avatar satori avatar wrodriguez-dbx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropbox-sdk-go-unofficial's Issues

Is there any plan to release a new version?

Before you start

No

What is your question?

Is there any plan to release a new version?

Versions

  • What version of the SDK are you using?
    v5.6.0
  • What version of the language are you using?
    golang 1.15
  • What platform are you using? (if applicable)
    N/A

We use this sdk in beyondstorage/go-service-dropbox#12 (comment) , and we want to track on stable release instead of git version.

And we want to include features like both UploadSessionTypeSequential and UploadSessionTypeConcurrent.

Upload too long files give: cannot unmarshal object into Go struct field UploadAPIError.error of type string

Uploading a too long path causes dropbox api endpoint to return

{"error_summary": "path/malformed_path/.", "error": {".tag": "path", "reason": {".tag": "malformed_path"}, "upload_session_id": ""}}

However this is not interpreted correctly by the SDK and it in turn reports json: cannot unmarshal object into Go struct field UploadAPIError.error of type string

Here is the full transaction

2017/11/07 22:36:24 DEBUG : HTTP REQUEST (req 0xc420468100)
2017/11/07 22:36:24 DEBUG : POST /2/files/upload HTTP/1.1
Host: content.dropboxapi.com
User-Agent: rclone/v1.38-DEV
Transfer-Encoding: chunked
Authorization: XXXX
Content-Type: application/octet-stream
Dropbox-Api-Arg: {"path":"/secret/i8da06u2uj2i1m3q6eq72ilb7ncjhaf3v9d2581cu63k4dbceon7b35c8gjdlip6hbfkgm7c6oucjbijla96tkr1aa17su2ipl3n5kg87vvgup7r9lfap5cosuj2tnkq92qhgl73djkutpvt8e1h85ofu5jtm1ldja1tifhnjb25m7dk87l1qg7g2ge72s5ge2n2eebirgrhrpg1dc1tbrga8bfrb48etb25fl7do1mtlsjp5h7026736fthh105k6qd52fja90rqmjt9mir1s44eofat41bnusmdhsph0ubr8akv9gia096odep2l4mkve5bnkm1m0j1m7du79rmj2s8re1n27qom6erar8g174j625hokvqfq4bnuddrssm68ib755k0emp75abo3nohonp4","mode":{".tag":"overwrite"},"autorename":false,"client_modified":"2017-11-07T22:34:55Z","mute":false}
Accept-Encoding: gzip

35
[snip binary data]
0

Response

2017/11/07 22:36:24 DEBUG : HTTP RESPONSE (req 0xc420468100)
2017/11/07 22:36:24 DEBUG : HTTP/1.1 409 path/malformed_path/.
Transfer-Encoding: chunked
Connection: keep-alive
Content-Type: application/json
Date: Tue, 07 Nov 2017 22:36:24 GMT
Server: nginx
X-Dropbox-Request-Id: 721aaea9fde2b8db3ee11da8b1325252
X-Robots-Tag: noindex, nofollow, noimageindex

84
{"error_summary": "path/malformed_path/.", "error": {".tag": "path", "reason": {".tag": "malformed_path"}, "upload_session_id": ""}}
0

And the error that was reported by the SDK

2017/11/07 22:36:24 ERROR : Failed to copy: upload failed: json: cannot unmarshal object into Go struct field UploadAPIError.error of type string

This code in files/client.go in the Upload function must be responsible for the error

	if resp.StatusCode == http.StatusConflict {
		var apiError UploadAPIError
		err = json.Unmarshal(body, &apiError)
		if err != nil {
			return
		}
		err = apiError
		return
	}

Which looks OK - so not sure what is going on yet!

Possible feature request: Use a team OAuth token to traverse files for users

I'm doing some work that involves walking across the entire document tree for all users. Using the API, it seems there's no explicit affordance for supplying a user header or URL param. When I attempt to, I find the following error message:

Could not list Dropbox folder: Error in call toAPI function "files/list_folder": This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team. Since your API app key has team member file access permissions, you can operate on a team member's Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user https://www.dropbox.com/developers/documentation/http/teams.

I'm curious if adding the ability to specify headers in the ListFolderArg object would be a welcome addition (which I'm happy to submit a pull request for). Or for the URL params. Lastly, if I'm just doing this the wrong way, I'd welcome a shove in the proper direction.

http 500 error on listfolder with propertygroups

Hello,

I created the template, etc and confirmed that the key / value paris are in fact saved via python sdk.

Listing contents of directory works fine, but as soon as I give it a template id i get 500 errors:

resp, err := ff.ListFolder(&df.ListFolderArg{Path: "", IncludePropertyGroups: &dp.TemplateFilterBase{FilterSome: []string{"ptid:abc123"}}})

if err != nil {
log.Println("list folder error ", err)
return
}

That produces:

2019/08/14 17:58:40 arg: &{ false false false false false 0 0xc000094cf0}

2019/08/14 17:58:40 req: &{POST https://api.dropboxapi.com/2/files/list_folder HTTP/1.1 1 1 map[Content-Type:[application/json]] {0xc000094fc0} 0x642860 240 [] false api.dropboxapi.com map[] map[] map[] }

2019/08/14 17:58:41 resp: &{500 Internal Server Error 500 HTTP/2.0 2 0 map[Content-Disposition:[attachment; filename='error'] Content-Length:[0] Content-Security-Policy:[sandbox; frame-ancestors 'none'] Content-Type:[text/plain; charset=utf-8] Date:[Thu, 15 Aug 2019 00:58:41 GMT] Server:[nginx] X-Content-Type-Options:[nosniff] X-Dropbox-Request-Id:[e09483645172874f23645269b02c68e0] X-Frame-Options:[DENY]] 0xc0003b6fc0 0 [] false false map[] 0xc00010c200 0xc00036ed10}

500 server errors causing "unexpected end of JSON input" errors

For example during a multipart upload I got this

2017/11/20 22:09:15 DEBUG : HTTP REQUEST (req 0xc42adc2d00)
2017/11/20 22:09:15 DEBUG : POST /2/files/upload_session/append_v2 HTTP/1.1
Host: content.dropboxapi.com
User-Agent: rclone/v1.38-167-g49a9a817-dump-response
Content-Length: 0
Authorization: XXXX
Content-Type: application/octet-stream
Dropbox-Api-Arg: {"cursor":{"session_id":"AAAAAAAAswW3y5-Q1EPD7Q","offset":6979321856},"close":false}
Accept-Encoding: gzip
2017/11/20 22:09:34 DEBUG : HTTP RESPONSE (req 0xc42adc2d00)
2017/11/20 22:09:34 DEBUG : HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
Date: Mon, 20 Nov 2017 22:09:34 GMT
Server: nginx
X-Dropbox-Request-Id: 9c5973e7e695c0ec4d6747ebbb2ca679
X-Robots-Tag: noindex, nofollow, noimageindex

0

This error was returned by the SDK

unexpected end of JSON input

Indicating that the SDK tried to parse the result of the 500 error response.

Oauth flow using the standard oauth2 lib doesn't seem to work

I've mostly been learning go while using this SDK, so it is very possible I am doing something wrong, but on the off chance you can help I am posting here.

It doesn't seem like the dropbox oauth flow works with the oauth2 library out of the box. From what I can tell, it looks like the /oauth2/authorize endpoint works fine, but the /oauth2/token endpoint expects some params that aren't provided by default, and I have no idea how to tell the Exchange method of oauth2.Config to pass in extra params.

I can get around this by writing some custom code, but I was just wondering if you had any better suggestions. Thanks!

C++ Plugin For Unreal

Why is this feature valuable to you? Does it solve a problem you're having?
It would be nice if we could have a dropbox plugin for Unreal engine as we would like use dropbox features in our game like importing a file from dropbox to the game folder at runtime.

Describe the solution you'd like
To be able to select a file from dropbox and import it into the game at runtime

Describe alternatives you've considered
none

Additional context
none

dropbox/files/client.go: if status code is 409 use the response body not header for error parsing

In case a status code 409 is returned from the API, the response body contains the error JSON not the Dropbox-API-Resultheader.

For example in the Download method on line 1369 the content variable should be used in the json.Unmarshal statement not the body. The body variable will be empty in case of a 409.

I encountered the possible bug when I was testing to download a file which does not exists, expecting a DropboxAPIError with the Tag not_found but got unexpected end of JSON input which is probably caused by passing an empty variable to the json.Unmarshal

Export appImpl

Since appImpl structs are not exported it is hard to make a wrapper or to include dbox inside own struct. For example, you can't write something like this.

type MyApp struct {
    db *files.appImpl
}

And it is actually bad Go practice for exported functions (i.e. files.New()) to return un-exported types (i.e. files.appImpl)

Can't upload files with emojis in the filename

Dropbox doesn't support emojis from the Emoji 12.0 standard (released in 2019). This error occurs:

json: cannot unmarshal object into Go struct field UploadAPIError.error of type string

https://help.dropbox.com/installs-integrations/sync-uploads/files-not-syncing#incompatible

Note: Some emojis can also cause sync issues.

https://www.dropboxforum.com/t5/Files-folders/Dropbox-not-syncing-files-with-emojis-in-the-filename/m-p/346141/highlight/true#M52256

files: DeleteV2 method isn't working

When I tried the DeleteV2 method I get this error

json: cannot unmarshal object into Go struct field DeleteResult.metadata of type files.IsMetadata

The HTTP transaction looks like this

request

2017/08/08 10:37:41 DEBUG : HTTP REQUEST (req 0xc4201e0700)
2017/08/08 10:37:41 DEBUG : POST /2/files/delete_v2 HTTP/1.1
Host: api.dropboxapi.com
User-Agent: rclone/v1.37-DEV
Content-Length: 48
Authorization: XXXX
Content-Type: application/json
Accept-Encoding: gzip

{"path":"/rclone-test-nuhexes9qaroxer3desayuz2"}

response

2017/08/08 10:37:42 DEBUG : HTTP RESPONSE (req 0xc4201e0700)
2017/08/08 10:37:42 DEBUG : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json
Date: Tue, 08 Aug 2017 09:37:42 GMT
Pragma: no-cache
Server: nginx
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Dropbox-Request-Id: 9d6eb7365903bb2a425e751778a4c887
X-Frame-Options: SAMEORIGIN
X-Server-Response-Time: 628

e3
{"metadata": {".tag": "folder", "name": "rclone-test-nuhexes9qaroxer3desayuz2", "path_lower": "/rclone-test-nuhexes9qaroxer3desayuz2", "path_display": "/rclone-test-nuhexes9qaroxer3desayuz2", "id": "id:qqS0afUHwS0AAAAAAABZ2g"}}
0

The verbose logging from the SDK looks like this

2017/08/08 10:41:09 arg: &{/rclone-test-gosocik0bewamen9sufotef3}
2017/08/08 10:41:09 req: &{POST https://api.dropboxapi.com/2/files/delete_v2 HTTP/1.1 1 1 map[Content-Type:[application/json]] {0xc420195ef0} 0x670830 48 [] false api.dropboxapi.com map[] map[] <nil> map[]   <nil> <nil> <nil> <nil>}
2017/08/08 10:41:10 resp: &{200 OK 200 HTTP/1.1 1 1 map[Date:[Tue, 08 Aug 2017 09:41:10 GMT] Pragma:[no-cache] Content-Type:[application/json] X-Frame-Options:[SAMEORIGIN] X-Server-Response-Time:[643] Vary:[Accept-Encoding] Cache-Control:[no-cache] X-Dropbox-Request-Id:[de7731f3a5db4d54dec94067c74b644c] Server:[nginx] Connection:[keep-alive] X-Content-Type-Options:[nosniff]] 0xc42022dce0 -1 [chunked] false true map[] 0xc4201bce00 0xc42023c840}
2017/08/08 10:41:10 body: [123 34 109 101 116 97 100 97 116 97 34 58 32 123 34 46 116 97 103 34 58 32 34 102 111 108 100 101 114 34 44 32 34 110 97 109 101 34 58 32 34 114 99 108 111 110 101 45 116 101 115 116 45 103 111 115 111 99 105 107 48 98 101 119 97 109 101 110 57 115 117 102 111 116 101 102 51 34 44 32 34 112 97 116 104 95 108 111 119 101 114 34 58 32 34 47 114 99 108 111 110 101 45 116 101 115 116 45 103 111 115 111 99 105 107 48 98 101 119 97 109 101 110 57 115 117 102 111 116 101 102 51 34 44 32 34 112 97 116 104 95 100 105 115 112 108 97 121 34 58 32 34 47 114 99 108 111 110 101 45 116 101 115 116 45 103 111 115 111 99 105 107 48 98 101 119 97 109 101 110 57 115 117 102 111 116 101 102 51 34 44 32 34 105 100 34 58 32 34 105 100 58 113 113 83 48 97 102 85 72 119 83 48 65 65 65 65 65 65 65 66 90 54 81 34 125 125]

non-auth endpoints still send an Authorization header

I encountered this with list_folder/longpoll. Even though it tries to remove the Authorization header, it actually gets added later by the transport, which used by everything in this package.

So without restructuring the client/transport to support going around the oauth2 transport entirely, everything gets the Authorization header.

This results in the Dropbox API rejecting the request with Your request includes an Authorization header, but this function does not use it.

Make verbose output target configurable?

Hi,
I see all the verbose outputs use the default log log.Printf and friends. I need to keep track of all outbound traffic, so these logs are useful, and I'm able to capture them with log.SetOutput() no problem.
It can be problematic when I am already using the global default log methods.

I understand this code is generated with stone, so my question is if it would be easy to set a custom logger via the api itself instead of having to wedge a different writer behind the default logger?

MoveV2 and CopyV2 broken

Both MoveV2 and CopyV2 methods fail with

json: cannot unmarshal object into Go struct field RelocationResult.metadata of type files.IsMetadata

I think RelocationResult needs the same treatment as was applied in #22 in particular 3509425

Update documentation to import from /v6/dropbox

Describe the bug
Trying to upgrade to 6.0.x but documentation still mentions importing:
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox

I believe this should be changed to /v6/dropbox/...

To Reproduce

    $ rm -Rf $GOPATH/src/github.com/dropbox
    $ go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox
    go get: module github.com/dropbox/dropbox-sdk-go-unofficial@upgrade found (v6.0.1+incompatible), but does not contain package github.com/dropbox/dropbox-sdk-go-unofficial/dropbox

Expected Behavior

    $ go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox
    go: downloading github.com/dropbox/dropbox-sdk-go-unofficial/dropbox v6.0.1
    go get: added github.com/dropbox/dropbox-sdk-go-unofficial/dropbox v6.0.1

Actual Behavior

    $ go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox
    go get: module github.com/dropbox/dropbox-sdk-go-unofficial@upgrade found (v6.0.1+incompatible), but does not contain package github.com/dropbox/dropbox-sdk-go-unofficial/dropbox

Versions

  • What version of the SDK are you using? upgrading from v5.9.4
  • What version of the language are you using? Go 1.16
  • What platform are you using? (if applicable) Ubuntu 20.04

Additional context
Just adding /v6/, I'm correctly downloading the new version:

    $ go get github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/
    go: downloading github.com/dropbox/dropbox-sdk-go-unofficial/v6 v6.0.1
    go get: added github.com/dropbox/dropbox-sdk-go-unofficial/v6 v6.0.1

OAuth2 flows aren't implemented

Why is this feature valuable to you? Does it solve a problem you're having?
The OAuth2 flows are not implemented in this SDK. I understand that we can use client_id and client_secret to exchange an auth_token to get the access_token & use it to init the dropbox-handle on which we perform all the operations.

But how about refreshing the access_tokens? I see that equivalent flows exist in Python SDK https://github.com/dropbox/dropbox-sdk-python/blob/main/dropbox/oauth.py

Describe the solution you'd like
Equivalent to OAuth2 flows in Python SDK https://github.com/dropbox/dropbox-sdk-python/blob/main/dropbox/oauth.py

Describe alternatives you've considered
I could manually write the OAuth2 flows in my application but its generic enough to add it to the SDK here.

Additional context
None

Retry-After header not visible to clients

It states in the data ingress guide:

Rate limited responses include a Retry-After header that provides the duration, in seconds, your app should wait before retrying the request to avoid a subsequent rate limit response.

Unfortunately these headers are not surfaced by the API.

A typical response looks like this

HTTP/1.1 429 too_many_write_operations/.
Transfer-Encoding: chunked
Connection: keep-alive
Content-Type: application/json
Date: Thu, 02 Nov 2017 14:25:01 GMT
Retry-After: 1
Server: nginx
X-Dropbox-Request-Id: XXX
X-Robots-Tag: noindex, nofollow, noimageindex

6c
{"error_summary": "too_many_write_operations/.", "error": {"reason": {".tag": "too_many_write_operations"}}}
0

The easiest way to fix this would be to add a RetryAfter field to the base APIError struct, eg

// APIError is the base type for endpoint-specific errors.
type APIError struct {
	ErrorSummary string `json:"error_summary"`
	RetryAfter time.Duration
}

And fill this from the RetryAfter Header if it was found.

This would need quite a bit of patching though so you may have a better idea?

EDIT

Though it might actually be preferable to return all the HTTP headers in the struct and just make a method to retrieve RetryAfter...

ReportsGetStorage incorrectly encodes dates

Supplying a DateRange to ReportsGetStorage results in a full time being sent to the api, rather than just a YYYY-MM-DD date as the spec requests, so an error is returned

Passing nil works as expected in terms of using a default range.

package main

import (
        "fmt"
        "log"
        "time"

        "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
        "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team"
)

const token = "my-token"

func main() {
        client := team.New(dropbox.Config{Token: token})

        resp, err := client.ReportsGetStorage(&team.DateRange{
                StartDate: time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC),
                EndDate:   time.Date(2020, time.March, 1, 0, 0, 0, 0, time.UTC),
        })

        if err != nil {
                log.Fatal(err)
        }

        fmt.Println(resp)
}

results in:

2020/04/20 21:57:46 Error in call to API function "team/reports/get_storage": request body: start_date: unconverted data remains: T00:00:00Z

Travis job failed in Intel

Hi All,
I am using Travis-CI to run jobs on Intel architecture but all the jobs are failing stating "Package not found". Logs are below

$ git submodule update --init --recursive

0.01s5.33s$ travis_setup_go

go version go1.9.7 linux/amd64

$ export GOPATH="/home/travis/gopath"

$ export PATH="/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.9.7.linux.amd64/bin:/home/travis/bin:/home/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbrew/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/gems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/travis/.rvm/rubies/ruby-2.5.3/bin:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.3/bin:/usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.rvm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin"

$ export GO111MODULE="auto"

$ gimme version

v1.5.4

$ go version

go version go1.9.7 linux/amd64
go.env

$ go env
install

2.64s$ go get -u golang.org/x/oauth2

0.00s$ set -e

The command "set -e" exited with 0.

$ GOOS=linux GOARCH=amd64 go install ./dropbox/...

dropbox/async/types.go:27:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox (from $GOPATH)

dropbox/contacts/client.go:30:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth (from $GOPATH)

dropbox/files/client.go:32:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/async" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/async (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/async (from $GOPATH)

dropbox/files/client.go:34:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties (from $GOPATH)

dropbox/paper/types.go:30:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sharing" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sharing (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sharing (from $GOPATH)

dropbox/sharing/types.go:30:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files (from $GOPATH)

dropbox/sharing/types.go:31:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/seen_state" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/seen_state (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/seen_state (from $GOPATH)

dropbox/sharing/types.go:32:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common (from $GOPATH)

dropbox/sharing/types.go:33:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users (from $GOPATH)

dropbox/team/types.go:31:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_policies" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_policies (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_policies (from $GOPATH)

dropbox/team_log/types.go:31:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team (from $GOPATH)

dropbox/users/types.go:29:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common (from $GOPATH)

dropbox/users/types.go:32:2: cannot find package "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users_common" in any of:

/home/travis/.gimme/versions/go1.9.7.linux.amd64/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users_common (from $GOROOT)

/home/travis/gopath/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users_common (from $GOPATH)

=============

Please look into it.

What is the best way to view files in non default namespaces?

I'm trying to use namespaces to read users team drives. I'm using the users.GetCurrentAccount() to get the namespaces.

I read in the docs that I can use an ns: prefix (eg ns:12345) on the path. However this doesn't seem to work :-(

I don't know whether this is me doing something stupid or not, but I I opened this query on the developer API forum with some plain curl examples. The equivalents using this SDK don't seem to work either.

However using the Dropbox-API-Path-Root: header does seem to work. I can set this using the dropbox.Config.HeaderGenerator however that seems like it probably isn't the intended way!

	config := dropbox.Config{
		HeaderGenerator: func(hostType string, style string, namespace string, route string) map[string]string {
			return map[string]string{
				"Dropbox-API-Path-Root": `{".tag": "namespace_id", "namespace_id": "12345"}`,
			}
		},
	}

Anyway, apologies in advance if there is a really obvious answer to this question that I've missed!

Can't not supply an expires in /sharing/create_shared_link_with_settings

Describe the bug

I'd like to create a sharing link with supplying sharing.SharedLinkSettings but without supplying sharing.SharedLinkSettings.Expires

To Reproduce

Submit a request like this

	createArg := sharing.CreateSharedLinkWithSettingsArg{
		Path: absPath,
		Settings: &sharing.SharedLinkSettings{
			RequestedVisibility: &sharing.RequestedVisibility{
				dropbox.Tagged{sharing.RequestedVisibilityPublic},
			},
			Audience: &sharing.LinkAudience{
				dropbox.Tagged{sharing.LinkAudiencePublic},
			},
			Access: &sharing.RequestedLinkAccessLevel{
				dropbox.Tagged{sharing.RequestedLinkAccessLevelViewer},
			},
		},
	}
	var linkRes sharing.IsSharedLinkMetadata
	linkRes, err = f.sharing.CreateSharedLinkWithSettings(&createArg)

The actual JSON submitted to the endpoint is this (formatted for readability)

{
  "path": "/hello.txt",
  "settings": {
    "requested_visibility": {
      ".tag": "public"
    },
    "expires": "0001-01-01T00:00:00Z",
    "audience": {
      ".tag": "public"
    },
    "access": {
      ".tag": "viewer"
    }
  }
}

Note the "expires": "0001-01-01T00:00:00Z"

Expected Behavior

I would expect the expires field to be missing or possibly empty string

Actual Behavior

There may be a special case for this in the dropbox API, but expires is not supported by a non enterprise dropbox, so if you supply anything in the expires you get

{
  "error_summary": "settings_error/not_authorized/.",
  "error": {
    ".tag": "settings_error",
    "settings_error": {
      ".tag": "not_authorized"
    }
  }
}

Versions

This reproduces with the SDK at master

Additional context

Because time.Time is struct, its empty value is all the fields empty, hence the "0001-01-01T00:00:00Z".

A patch like this does fix the problem - making the time.Time into a pointer type so it can be omitted properly.

diff --git a/dropbox/sharing/types.go b/dropbox/sharing/types.go
index 085cda4..6ab9870 100644
--- a/dropbox/sharing/types.go
+++ b/dropbox/sharing/types.go
@@ -3922,7 +3922,7 @@ type SharedLinkSettings struct {
        LinkPassword string `json:"link_password,omitempty"`
        // Expires : Expiration time of the shared link. By default the link won't
        // expire.
-       Expires time.Time `json:"expires,omitempty"`
+       Expires *time.Time `json:"expires,omitempty"`
        // Audience : The new audience who can benefit from the access level
        // specified by the link's access level specified in the `link_access_level`
        // field of `LinkPermissions`. This is used in conjunction with team

However that needs to be done in the generator. It is also not backwards compatible.

An alternate patch would be to make a special case MarshalJSON for the Expires which checked expires = time.Time{} and omitted it.

unexpected end of input error for DeleteV2

The SDK appears to be calling the v1 endpoint, instead of v2. If I change the endpoint manually it works. Also appears to the same for Move/Copy

2018/11/16 19:16:21 arg: &{/test }
2018/11/16 19:16:21 req: &{POST https://api.dropboxapi.com/2/files/delete HTTP/1.1 1 1 map[Content-Type:[application/json]] {0xc0001ba270} 0x6498a0 16 [] false api.dropboxapi.com map[] map[] map[] }

// This should be delete_v2?
Line 1276 of ~/go/src/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files/client.go
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete", headers, bytes.NewReader(b))

team_log.GetEvents fails for some categories

While calling team_log.GetEvents, Some categories of events result in a json decode error; latest observed with the sharing category - have exported millions of events successfully from other cateogry types with the same call

Captured a result with debug logging, included below with anonymized values:

package main

import (
        "encoding/json"
        "log"

        "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_log"
)

var badResultData = []byte(`{"events": [{"timestamp": "2017-01-01T06:51:00Z", "event_category": {".tag": "sharing"}, "actor": {".tag": "user", "user": {".tag": "team_member", "account_id": "dbid:AADaccountid", "display_name": "Ann Other", "email": "[email protected]", "team_member_id": "dbmid:AACkMLh-teammemberid"}}, "origin": {"geo_location": {"city": "San Jose", "region": "California", "country": "US", "ip_address": "1.2.3.4"}, "access_method": {".tag": "end_user", "end_user": {".tag": "web", "session_id": "dbwsid:1"}}}, "involve_non_team_member": false, "context": {".tag": "team_member", "account_id": "dbid:AADpbBlKT-accountid", "display_name": "Ann Other", "email": "[email protected]", "team_member_id": "dbmid:AACkMLh-teammemberid"}, "participants": [], "assets": [{".tag": "folder", "path": {"contextual": "/New Hire Information", "namespace_relative": {"ns_id": "922"}}, "file_id": "id:IOeFtIPM"}], "event_type": {".tag": "shared_link_view", "description": "Opened shared link"}, "details": {".tag": "shared_link_view_details", "shared_link_owner": {".tag": "team_member", "account_id": "dbid:AADrNRWvjz-accountid", "display_name": "Agent Smith", "email": "[email protected]", "team_member_id": "dbmid:AACFYvnmember2"}}}], "cursor": "AACr59YQrhc0_", "has_more": true}`)

func main() {
        var result team_log.GetTeamEventsResult

        err := json.Unmarshal(badResultData, &result)
        if err != nil {
                log.Fatal(err)
        }
        log.Printf("%#v", result)
}

Results in:

2020/04/27 15:54:51 json: cannot unmarshal object into Go struct field TeamEvent.events.details of type team_log.IsUserLogInfo
exit status 1

UploadSessionFinishBatch endpoint does not work

The UploadSessionFinishBatch endpoint does not work. This is due to CommitInfo.ClientModified's default value being 0001-01-01 00:00:00 +0000 UTC. Setting ClientModified to the current time does not work either as the generated JSON includes milliseconds which the API rejects.

Setting ClientModified to be a pointer to time.Time fixes the first issue but not the second.

Code example for folder listing

Hi guys, could you please give me the idea how can I get the data from the received list of entries for the folder. all I can see entity has IsMetadata method and how can I convert it to structs that represents files/folders correct or "extract" data any other way?

My example code works correct (works correct, receive data from dropbox, but only can dump the entity)

import (
    "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
    "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
)
...
dbf := files.New(config)
farg := files.ListFolderArg{}
listFolder, err := dbf.ListFolder(&farg)

for _, entry := range listFolder.Entries {
  // how can I get the data from entry here? 
}

Unable to use custom http client.

Attempting to use github.com/linki/instrumented_http as a http client.

config := dropbox.Config{
	Token:  token,
	Client: instrumentedHttpClient,
}

if _, err := files.New(config).ListFolder(&files.ListFolderArg{
	Path:      "",
	Recursive: false,
	Limit:     1,
}); err != nil {
	log.Fatal(err)
}

Produces:

2018/03/20 11:31:41 Error in call to API function "files/list_folder": Must provide HTTP header "Authorization" or URL parameter "authorization".

Could not use batch copy/delete/move operations

Thank you for maintaining great SDK. I found the following issues during implementing mass file operation tool.

AsyncJobId

Batch operations usually require using AsyncJobId. But there is no AsyncJobId in a response of {Copy|Move|Delete}Batch.
Type *BatchLaunch also don't have AsyncJobId.

*BatchCheck fail parsing response

I tried only for MoveBatch. When result tag == "complete", MoveBatchCheck fail to parse entities.

Route versioning causing `DeleteV2` to call the v1 API

Calling DeleteV2 on a directory causes an error unexpected end of JSON input to be returned instead of the actual error.

Tested with dd3c8f5 (head of master as of now).

Request

2018/12/22 16:12:49 DEBUG : HTTP REQUEST (req 0xc000106300)
2018/12/22 16:12:49 DEBUG : POST /2/files/delete HTTP/1.1
Host: api.dropboxapi.com
User-Agent: rclone/v1.45-DEV
Content-Length: 48
Authorization: XXXX
Content-Type: application/json
Accept-Encoding: gzip

{"path":"/rclone-test-sotadic5copuwoz8tefavop0"}

Response

2018/12/22 16:12:49 DEBUG : HTTP RESPONSE (req 0xc000106300)
2018/12/22 16:12:49 DEBUG : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json
Date: Sat, 22 Dec 2018 16:12:49 GMT
Pragma: no-cache
Server: nginx
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Dropbox-Request-Id: 627c3408ccbe2562f597fea7cad99959
X-Frame-Options: SAMEORIGIN
X-Server-Response-Time: 428

d5
{".tag": "folder", "name": "rclone-test-sotadic5copuwoz8tefavop0", "path_lower": "/rclone-test-sotadic5copuwoz8tefavop0", "path_display": "/rclone-test-sotadic5copuwoz8tefavop0", "id": "id:q
qS0afUHwS0AAAAAAAHDUQ"}
0

Which produces the error unexpected end of JSON input

This is quite clearly calling the v1 API - it should be calling delete_v2.

Using git bisect I found that the offending commit is 118eb01

$ git bisect bad
118eb0115111626cc1679ca95b8367b9f13653af is the first bad commit
commit 118eb0115111626cc1679ca95b8367b9f13653af
Author: Diwaker Gupta <[email protected]>
Date:   Wed Oct 10 22:30:33 2018 -0700

    Add support for route versioning.
    
    Also update API spec. Bumping revision to 5.0.0 -- I'm not aware of any
    breaking changes, but bumping major version anyways to raise awareness
    about route versioning.

:040000 040000 fa13db850e9ca26f417a2953908505709fe799bc 0b208896c25c03f13ed9c43b64ec6399af287871 M	dropbox
:040000 040000 e407af19578ceebfaecbbc8bca336ef1e618cc73 2d39e42d8ed6a9d6080affd1924e4b4d0b4e6fce M	generator

According to the documentation https://www.dropbox.com/developers/documentation/http/documentation#files-delete
This should be producing a JSON blob with an inner "metadata"

{
    "metadata": {
        ".tag": "file",
        "name": "Prime_Numbers.txt",
        "id": "id:a4ayc_80_OEAAAAAAAAAXw",
[snip]
    }
}

However that returned above looks like this (formatted) with no inner metadata tag.

{
  ".tag": "folder",
  "name": "rclone-test-lidaqez4xenaqew0lenameq6",
  "path_lower": "/rclone-test-lidaqez4xenaqew0lenameq6",
  "path_display": "/rclone-test-lidaqez4xenaqew0lenameq6",
  "id": "id:qqS0afUHwS0AAAAAAAHDTg"
}

That is what is causing IsMetadataFromJSON to fail

// IsMetadataFromJSON converts JSON to a concrete IsMetadata instance
func IsMetadataFromJSON(data []byte) (IsMetadata, error) {
	var t metadataUnion
	if err := json.Unmarshal(data, &t); err != nil {
		log.Printf("Unmarshal IsMetadataFromJSON #1: %v: %q", err, data)
		return nil, err
	}
	switch t.Tag {
	case "file":
		return t.File, nil

	case "folder":
		return t.Folder, nil

	case "deleted":
		return t.Deleted, nil

	}
	return nil, nil
}

The log message prints this showing the metadata is empty.

Unmarshal IsMetadataFromJSON #1: unexpected end of JSON input: ""

The ultimate cause seems to be the same as #47 - the SDK is calling the v1 delete rather than the v2 delete.

diff --git a/dropbox/files/client.go b/dropbox/files/client.go
index 55c53fe..c5e471f 100644
--- a/dropbox/files/client.go
+++ b/dropbox/files/client.go
@@ -1364,7 +1367,7 @@ func (dbx *apiImpl) DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) {
                headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
        }
 
-       req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete", headers, bytes.NewReader(b))
+       req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete_v2", headers, bytes.NewReader(b))
        if err != nil {
                return
        }

I will send a PR for this in just a moment :-)

files.New() returns an unexported type

This applies to all the sub modules, but I'll just use files as an example.

files.New(config) returns *files.apiImpl

Since apiImpl starts with a lower case letter it is private. In an external module you can't define a variable of type *files.apiImpl, which means that you can't pass the result from files.New() to a function, or put it in a structure which makes re-using these handles very difficult.

Is this deliberate?

Is running files.New() so cheap that you just do that whenever you want a new handle?

I notice that in the commands in dbxcli they are all written in a single function.

My preference would be for the apiImpl to become public APIClient.

Since the apiImpl is just a type alias of a public type this doesn't lose you any type security

type apiImpl dropbox.Context

ClientModified marshal format

2022/02/24 17:07:56 Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": client_modified: time data '2022-02-24T16:50:46.921728694+08:00' does not match format '%Y-%m-%dT%H:%M:%SZ'

image

should format as '%Y-%m-%dT%H:%M:%SZ'

Timestamps

Issue:
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": client_modified: time data '2017-07-15T16:09:11.172473155Z' does not match format '%Y-%m-%dT%H:%M:%SZ'

Problematic function files/client.go:3064

Go timestamps vs dropbox

in some structures such as CommitInfo # files/types.go:220 uses go time structs which are serialized as shown above (RFC3339 or most commonly used in JSON/Javascript as it seems json does not specify a time format).

I'm not sure if i'm doing something wrong here but some solutions would be

  • dropbox would 'change' to fully support rfc3339,
  • custom type based on time.Time implementing json marshaler interface

JSON unmarshal Error in files.Download for photos

I get a JSON unmarshal error while calling files.Download for photos. I seem to have narrowed it down to the unmarshalling of the metadata and can reproduce it with this program:

package main

import (
	"encoding/json"
	"log"

	"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
)

func main() {
	data := []byte(`{"name": "2016-05-21 13.31.39.jpg", "path_lower": "/camera uploads/2016-05-21 13.31.39.jpg", "path_display": "/Camera Uploads/2016-05-21 13.31.39.jpg", "id": "id:9Y45ew-EssAAAAAAAAAAAQ", "client_modified": "2016-05-21T20:31:39Z", "server_modified": "2016-05-28T06:33:30Z", "rev": "5436542a000c1f1f", "size": 1836182, "media_info": {".tag": "metadata", "metadata": {".tag": "photo", "dimensions": {"height": 3024, "width": 4032}, "time_taken": "2016-05-21T13:31:39Z"}}, "content_hash": "7ff3b6d6b017aac9f28a1b8a9f16d3ebd8ecc5841a7c42e6bbdf980f5a22fa84"}`)

	var md files.FileMetadata
	err := json.Unmarshal(data, &md)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("%#v", md)
}

this outputs:

$ go run main.go
2017/02/08 22:55:09 json: cannot unmarshal object into Go value of type files.IsMediaMetadata
exit status 1

Add context to dropbox http requests

Why is this feature valuable to you? Does it solve a problem you're having?
We have a service that executes requests to dropbox on given PubSub events. We want to stop all running http connections when an event is nacked or times out. Passing an event context to the dropbox requests will be a solution to the problem.

Describe the solution you'd like
One solution would be to add a context parameter to all client methods and pass that context to the http request. However, this solution modifies the methods' signatures and would not be backwards compatible.
Another solution would be to modify the arg struct parameter passed to the client method.
For example the files.Upload method accepts a CommitInfo struct. We could add a context field to that struct.

We could also provide a pull request with our changes if needed.

Describe alternatives you've considered
As an alternative we have concidered cloning the Go SDK locally and adding the modifications ourselves. However this modification seems generic enough to be added in the (un)official SDK. I believe that a lot of people would benefit from this.

Additional context
Abandoning http connections without closing them would cause connection leak.

Logging response body

Verbose logging prints the response body, when downloading a large file, this naturally results in a very large log. Is there any value in this?

I'm offering to remove it or put it behind a flag if there is a compelling reason to have it

Dropbox-Api-Arg needs encoding in the headers

An rclone user reported file name corruptions when uploading things to Dropbox with rclone - see rclone/rclone#3609 for background.

Greg K in the Dropbox developer forum was kind enough to explain the problem: https://www.dropboxforum.com/t5/API-Support-Feedback/Possible-bug-corrupting-file-names-with-certain-unicode-code/m-p/370538

In summary this was a result of:

  1. A change of code at Dropbox, now rolled back
  2. The Dropbox-Api-Arg header not being properly encoded

When rclone does an upload using the Upload method from the SDK an HTTP transaction like this gets sent:

2019/10/10 12:40:16 DEBUG : HTTP REQUEST (req 0xc000463900)
2019/10/10 12:40:16 DEBUG : POST /2/files/upload HTTP/1.1
Host: content.dropboxapi.com
User-Agent: rclone/v1.49.5
Transfer-Encoding: chunked
Authorization: XXXX
Content-Type: application/octet-stream
Dropbox-Api-Arg: {"path":"/tdir/Русский.txt","mode":{".tag":"overwrite"},"autorename":false,"client_modified":"2000-01-01T00:00:00Z","mute":false,"strict_conflict":false}
Accept-Encoding: gzip

0

Note how the UTF-8 characters are not encoded in the Dropbox-Api-Arg header.

In the documentation it states

If you use the Dropbox-API-Arg header, you need to make it "HTTP header safe". This means using JSON-style "\uXXXX" escape codes for the character 0x7F and all non-ASCII characters.

This is clearly not being done, hence the problem.

For example here the JSON encoded arguments are put straight into the header as far as I can see.

func (dbx *apiImpl) Upload(arg *CommitInfo, content io.Reader) (res *FileMetadata, err error) {
cli := dbx.Client
dbx.Config.LogDebug("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/octet-stream",
"Dropbox-API-Arg": string(b),
}
if dbx.Config.AsMemberID != "" {

json: cannot unmarshal object into Go struct field UploadAPIError.error of type string

This error

json: cannot unmarshal object into Go struct field UploadAPIError.error of type string

Is produced when trying to unmarshal this error message

2018/05/21 22:08:08 DEBUG : HTTP/1.1 409 path/malformed_path/
Transfer-Encoding: chunked
Connection: keep-alive
Content-Security-Policy: sandbox allow-forms allow-scripts
Content-Type: application/json
Date: Mon, 21 May 2018 20:08:08 GMT
Server: nginx
X-Dropbox-Request-Id: 4aa21beb57285ee06c448795c5130144
X-Robots-Tag: noindex, nofollow, noimageindex

99
{"error_summary": "path/malformed_path/", "error": {".tag": "path", "reason": {".tag": "malformed_path"}, "upload_session_id": "AAAAAAAAB0BBH11mLUv5Sg"}}
0

This is generated by this bit of code

if resp.StatusCode == http.StatusConflict {
var apiError UploadAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}

So it looks like the type of error being returned doesn't match

//UploadAPIError is an error-wrapper for the upload route
type UploadAPIError struct {
	dropbox.APIError
	EndpointError *UploadError `json:"error"`
}

This error was caused by an attempt to upload a file with a path that was too long

2018/05/21 22:08:07 DEBUG : POST /2/files/upload HTTP/1.1

error returned by files.Download unhelpful when response body is blank

When an invalid path is provided (e.g. "asdf.csv") as the path to a files.Download call, the returned APIError has an empty string as its ErrorSummary.

I.e. this:

result, content, err := c.files.Download(files.NewDownloadArg("asdf.csv"))
fmt.Println(err)

prints nothing.

The returned error is fine when a valid path is provided, but no file exists at that path ("path/not_found/..." is printed in this case)

Relevant code located at files/client.go:1693, which calls sdk.go:212.

A little digging suggests that this is due to the response body being empty. However, https://www.dropbox.com/developers/documentation/http/documentation#error-handling suggests that in the case of a 400 Bad Request status code, "The response body is a plaintext message with more information.".

This might be more properly fixed server side. However, perhaps APIError should also hold the response code, and in the case where ErrorSummary is blank, stringify into the response code plus a short error message instead?

Range headers

I'd like to be able to set Range headers on Download however DownloadArg has no place to put them.

I can work around by getting a TemporaryLink but that is an extra http transaction and probably more work for the dropbox servers.

I'm willing to send a PR to add this if given a steer as to exactly where. DownloadArg is auto generated and the autogenerator looks quite scary!

Update

On thinking about this some more...

I'll just note that Range requests are supported in the content download endpoints.

The best API for this might be to make a new DownloadHeaders call which takes an headers http.Header or a headers map[string]string. This would enable use of If-None-Match too. Then the Download method can just call DownloadHeaders with a nil headers parameter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.