dropbox / dbxcli

A command line client for Dropbox built using the Go SDK
Other
1.05k stars 101 forks source link

How to correctly specify the target directory for put? #152

Open g40 opened 3 years ago

g40 commented 3 years ago

It's a really simple question I think. How does one specify the target directory? In the first chunk of spew (below) my home folder has an existing directory called Pi0.

The second variety "works" but fails to deliver anything to the suggested folder.

Invoking the verbose option is really not helpful. See 3:

A simple example of correct usage would be most helpful. Any thoughts much appreciated.

1: $ dbxcli put db.txt Pi0
Uploading 6 B/6 B
Error: path/conflict/folder/..

2: $ dbxcli put db.txt /home/Pi0
Uploading 6 B/6 B

3: $ dbxcli -v put db.txt Pi0
2020/11/26 23:48:21 sdk.go:94: arg: &{/Pi0 0xc0000a67e0 false 2020-11-26 23:48:21 +0000 UTC false [] false}
2020/11/26 23:48:21 sdk.go:94: req: &{POST https://content.dropboxapi.com/2/files/upload HTTP/1.1 1 1 map[Content-Type:[application/octet-stream] Dropbox-Api-Arg:[{"path":"/Pi0","mode":{".tag":"overwrite"},"autorename":false,"client_modified":"2020-11-26T23:48:21Z","mute":false,"strict_conflict":false}]] {0xc00009e280} <nil> 0 [] false content.dropboxapi.com map[] map[] <nil> map[]   <nil> <nil> <nil> <nil>}
Uploading 6 B/6 B
2020/11/26 23:48:22 sdk.go:94: resp: &{409 Conflict 409 HTTP/1.1 1 1 map[X-Dropbox-Request-Id:[a3bf7ad5b00b41acbe134fcdab3d0ec0] X-Robots-Tag:[noindex, nofollow, noimageindex noindex, nofollow, noimageindex] Content-Security-Policy:[sandbox allow-forms allow-scripts] Date:[Thu, 26 Nov 2020 23:48:22 GMT] Content-Type:[application/json] Strict-Transport-Security:[max-age=31536000; includeSubDomains] Vary:[Accept-Encoding] Server:[envoy]] 0xc0002060a0 -1 [chunked] false true map[] 0xc000115100 0xc00018f970}
2020/11/26 23:48:22 sdk.go:94: body: {"error_summary": "path/conflict/folder/..", "error": {".tag": "path", "reason": {".tag": "conflict", "conflict": {".tag": "folder"}}, "upload_session_id": "AAAAAAAAAFhssHYafguGHg"}}
Error: path/conflict/folder/..

Versions:

$ dbxcli version
dbxcli version: v3.0.0
SDK version: 5.4.0
Spec version: 097e9ba

$ uname -a
Linux ubuntu 5.4.0-53-generic #59-Ubuntu SMP Wed Oct 21 09:38:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
kevingreenman commented 1 year ago

This is a pretty old issue, but here's my solution since I spent a while trying to figure it out today, and I suspect it may be helpful to others who search for this in the future. It seems that the target needs to include the whole file path (in the form <TARGET_DIR>/<FILE_NAME>), where TARGET_DIR is an absolute path from the root directory /. So for your example, assuming Pi0/ is in the root directory, the command would be:

dbxcli put db.txt /Pi0/db.txt