dropbox / dbxcli

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

`put` command is sending wrong client_modified timestamp #20

Closed waits closed 8 years ago

waits commented 8 years ago

When uploading a file with the put command the client_modified timestamp isn't being set. This is causing the SDK to send a default value of "0001-01-01T00:00:00Z", which Dropbox interprets as January 1, 2001 (before accounting for time zones). This incorrect value is displayed in the various Dropbox GUI apps.

This is easily confirmed with the -v flag (note "client_modified" on both lines):

$ dbxcli put -v test.rb
...
2016/06/12 22:16:06 impl.go:1270: req: &{POST https://content.dropboxapi.com/2/files/upload HTTP/1.1 1 1 map[Content-Type:[application/octet-stream] Dropbox-Api-Arg:[{"path":"/test.rb","mode":{".tag":"overwrite"},"autorename":false,"client_modified":"0001-01-01T00:00:00Z","mute":false}]] {0xc82007a460} 0 [] false content.dropboxapi.com map[] map[] <nil> map[]   <nil> <nil>}
...
2016/06/12 22:16:08 impl.go:1287: body: {"name": "test.rb", "path_lower": "/test.rb", "path_display": "/test.rb", "id": "id:ZoeZpsEyI3AAAAAAAAAAAQ", "client_modified": "2001-01-01T00:00:00Z", "server_modified": "2016-06-13T04:50:33Z", "rev": "d2580edd0ab3", "size": 2222}

Screenshot of how https://www.dropbox.com interprets this (in PST):

screen shot 2016-06-12 at 10 22 31 pm

API docs mentioning client_modified parameter.

diwakergupta commented 8 years ago

Interesting. The API docs do say this field is optional (https://www.dropbox.com/developers/documentation/http/documentation#files-upload), so the behavior does seem surprising. Ideally, Dropbox apps will show the server side timestamp by default, unless clients override. The PR looks good but I'll follow up with folks internally to figure out the desired behavior.