1gdrive 2====== 3 4 5## Overview 6gdrive is a command line utility for interacting with Google Drive. 7 8## News 9#### 28.05.2021 10gdrive is finally verified for using sensitive scopes which should fix the `This app is blocked` error. Note that the project name will show up as `project-367116221053` when granting access to you account. (I don't dare to change any more settings in the google console.) 11 12## Prerequisites 13None, binaries are statically linked. 14If you want to compile from source you need the [go toolchain](http://golang.org/doc/install). 15Version 1.5 or higher. 16 17## Installation 18### With [Homebrew](http://brew.sh) on Mac 19``` 20brew install gdrive 21``` 22### Other 23Download `gdrive` from one of the links below. On unix systems 24run `chmod +x gdrive` after download to make the binary executable. 25The first time gdrive is launched (i.e. run `gdrive about` in your 26terminal not just `gdrive`), you will be prompted for a verification code. 27The code is obtained by following the printed url and authenticating with the 28google account for the drive you want access to. This will create a token file 29inside the .gdrive folder in your home directory. Note that anyone with access 30to this file will also have access to your google drive. 31If you want to manage multiple drives you can use the global `--config` flag 32or set the environment variable `GDRIVE_CONFIG_DIR`. 33Example: `GDRIVE_CONFIG_DIR="/home/user/.gdrive-secondary" gdrive list` 34You will be prompted for a new verification code if the folder does not exist. 35 36## Compile from source 37```bash 38go get github.com/prasmussen/gdrive 39``` 40The gdrive binary should now be available at `$GOPATH/bin/gdrive` 41 42 43### Syncing 44Gdrive supports basic syncing. It only syncs one way at the time and works 45more like rsync than e.g. dropbox. Files that are synced to google drive 46are tagged with an appProperty so that the files on drive can be traversed 47faster. This means that you can't upload files with `gdrive upload` into 48a sync directory as the files would be missing the sync tag, and would be 49ignored by the sync commands. 50The current implementation is slow and uses a lot of memory if you are 51syncing many files. Currently only one file is uploaded at the time, 52the speed can be improved in the future by uploading several files concurrently. 53To learn more see usage and the examples below. 54 55## Client Credentials 56By default, gdrive uses OAuth2 client credentials (client id and secret) in 57order to allow it to use Google's Drive APIs on behalf of the user. The credentials 58are set inside gdrive by default. Unfortunately this means that the rate limit of 59API usage is shared amongst all gdrive users globally. It has become common for 60the rate limit to be exceeded, causing gdrive to stop stop working. 61 62To get around this, gdrive now supports loading external OAuth2 client credentials. 63 64Generate your new credentials in the Google API Console, name the credentials 65file `client_id.json` and move it to the gdrive config directory. 66Then delete `token_v2.json` to reauthenticate using the new credentials. 67 68One side effect to note is that existing sync directories will not work after the 69credentials change because sync sets credential specific properties on the files 70(appProperty). 71 72### Service Account 73For server to server communication, where user interaction is not a viable option, 74is it possible to use a service account, as described in this [Google document](https://developers.google.com/identity/protocols/OAuth2ServiceAccount). 75If you want to use a service account, instead of being interactively prompted for 76authentication, you need to use the `--service-account <serviceAccountCredentials>` 77global option, where `serviceAccountCredentials` is a file in JSON format obtained 78through the Google API Console, and its location is relative to the config dir. 79 80#### .gdriveignore 81Placing a .gdriveignore in the root of your sync directory can be used to 82skip certain files from being synced. .gdriveignore follows the same 83rules as [.gitignore](https://git-scm.com/docs/gitignore), except that gdrive only reads the .gdriveignore file in the root of the sync directory, not ones in any subdirectories. 84 85 86## Usage 87``` 88gdrive [global] list [options] List files 89gdrive [global] download [options] <fileId> Download file or directory 90gdrive [global] download query [options] <query> Download all files and directories matching query 91gdrive [global] upload [options] <path> Upload file or directory 92gdrive [global] upload - [options] <name> Upload file from stdin 93gdrive [global] update [options] <fileId> <path> Update file, this creates a new revision of the file 94gdrive [global] info [options] <fileId> Show file info 95gdrive [global] mkdir [options] <name> Create directory 96gdrive [global] share [options] <fileId> Share file or directory 97gdrive [global] share list <fileId> List files permissions 98gdrive [global] share revoke <fileId> <permissionId> Revoke permission 99gdrive [global] delete [options] <fileId> Delete file or directory 100gdrive [global] sync list [options] List all syncable directories on drive 101gdrive [global] sync content [options] <fileId> List content of syncable directory 102gdrive [global] sync download [options] <fileId> <path> Sync drive directory to local directory 103gdrive [global] sync upload [options] <path> <fileId> Sync local directory to drive 104gdrive [global] changes [options] List file changes 105gdrive [global] revision list [options] <fileId> List file revisions 106gdrive [global] revision download [options] <fileId> <revId> Download revision 107gdrive [global] revision delete <fileId> <revId> Delete file revision 108gdrive [global] import [options] <path> Upload and convert file to a google document, see 'about import' for available conversions 109gdrive [global] export [options] <fileId> Export a google document 110gdrive [global] about [options] Google drive metadata, quota usage 111gdrive [global] about import Show supported import formats 112gdrive [global] about export Show supported export formats 113gdrive version Print application version 114gdrive help Print help 115gdrive help <command> Print command help 116gdrive help <command> <subcommand> Print subcommand help 117``` 118 119#### List files 120``` 121gdrive [global] list [options] 122 123global: 124 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 125 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 126 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 127 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 128 129options: 130 -m, --max <maxFiles> Max files to list, default: 30 131 -q, --query <query> Default query: "trashed = false and 'me' in owners". See https://developers.google.com/drive/search-parameters 132 --order <sortOrder> Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy 133 --name-width <nameWidth> Width of name column, default: 40, minimum: 9, use 0 for full width 134 --absolute Show absolute path to file (will only show path from first parent) 135 --no-header Dont print the header 136 --bytes Size in bytes 137``` 138 139List file in subdirectory 140 141 142``` 143./gdrive list --query " 'IdOfTheParentFolder' in parents" 144``` 145 146#### Download file or directory 147``` 148gdrive [global] download [options] <fileId> 149 150global: 151 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 152 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 153 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 154 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 155 156options: 157 -f, --force Overwrite existing file 158 -r, --recursive Download directory recursively, documents will be skipped 159 --path <path> Download path 160 --delete Delete remote file when download is successful 161 --no-progress Hide progress 162 --stdout Write file content to stdout 163 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 164``` 165 166#### Download all files and directories matching query 167``` 168gdrive [global] download query [options] <query> 169 170global: 171 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 172 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 173 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 174 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 175 176options: 177 -f, --force Overwrite existing file 178 -r, --recursive Download directories recursively, documents will be skipped 179 --path <path> Download path 180 --no-progress Hide progress 181``` 182 183#### Upload file or directory 184``` 185gdrive [global] upload [options] <path> 186 187global: 188 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 189 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 190 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 191 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 192 193options: 194 -r, --recursive Upload directory recursively 195 -p, --parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents 196 --name <name> Filename 197 --description <description> File description 198 --no-progress Hide progress 199 --mime <mime> Force mime type 200 --share Share file 201 --delete Delete local file when upload is successful 202 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 203 --chunksize <chunksize> Set chunk size in bytes, default: 8388608 204``` 205 206#### Upload file from stdin 207``` 208gdrive [global] upload - [options] <name> 209 210global: 211 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 212 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 213 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 214 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 215 216options: 217 -p, --parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents 218 --chunksize <chunksize> Set chunk size in bytes, default: 8388608 219 --description <description> File description 220 --mime <mime> Force mime type 221 --share Share file 222 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 223 --no-progress Hide progress 224``` 225 226#### Update file, this creates a new revision of the file 227``` 228gdrive [global] update [options] <fileId> <path> 229 230global: 231 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 232 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 233 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 234 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 235 236options: 237 -p, --parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents 238 --name <name> Filename 239 --description <description> File description 240 --no-progress Hide progress 241 --mime <mime> Force mime type 242 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 243 --chunksize <chunksize> Set chunk size in bytes, default: 8388608 244``` 245 246#### Show file info 247``` 248gdrive [global] info [options] <fileId> 249 250global: 251 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 252 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 253 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 254 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 255 256options: 257 --bytes Show size in bytes 258``` 259 260#### Create directory 261``` 262gdrive [global] mkdir [options] <name> 263 264global: 265 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 266 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 267 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 268 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 269 270options: 271 -p, --parent <parent> Parent id of created directory, can be specified multiple times to give many parents 272 --description <description> Directory description 273``` 274 275#### Share file or directory 276``` 277gdrive [global] share [options] <fileId> 278 279global: 280 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 281 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 282 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 283 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 284 285options: 286 --role <role> Share role: owner/writer/commenter/reader, default: reader 287 --type <type> Share type: user/group/domain/anyone, default: anyone 288 --email <email> The email address of the user or group to share the file with. Requires 'user' or 'group' as type 289 --discoverable Make file discoverable by search engines 290 --revoke Delete all sharing permissions (owner roles will be skipped) 291``` 292 293#### List files permissions 294``` 295gdrive [global] share list <fileId> 296 297global: 298 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 299 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 300 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 301 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 302``` 303 304#### Revoke permission 305``` 306gdrive [global] share revoke <fileId> <permissionId> 307 308global: 309 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 310 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 311 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 312 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 313``` 314 315#### Delete file or directory 316``` 317gdrive [global] delete [options] <fileId> 318 319global: 320 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 321 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 322 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 323 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 324 325options: 326 -r, --recursive Delete directory and all it's content 327``` 328 329#### List all syncable directories on drive 330``` 331gdrive [global] sync list [options] 332 333global: 334 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 335 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 336 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 337 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 338 339options: 340 --no-header Dont print the header 341``` 342 343#### List content of syncable directory 344``` 345gdrive [global] sync content [options] <fileId> 346 347global: 348 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 349 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 350 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 351 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 352 353options: 354 --order <sortOrder> Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy 355 --path-width <pathWidth> Width of path column, default: 60, minimum: 9, use 0 for full width 356 --no-header Dont print the header 357 --bytes Size in bytes 358``` 359 360#### Sync drive directory to local directory 361``` 362gdrive [global] sync download [options] <fileId> <path> 363 364global: 365 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 366 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 367 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 368 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 369 370options: 371 --keep-remote Keep remote file when a conflict is encountered 372 --keep-local Keep local file when a conflict is encountered 373 --keep-largest Keep largest file when a conflict is encountered 374 --delete-extraneous Delete extraneous local files 375 --dry-run Show what would have been transferred 376 --no-progress Hide progress 377 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 378``` 379 380#### Sync local directory to drive 381``` 382gdrive [global] sync upload [options] <path> <fileId> 383 384global: 385 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 386 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 387 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 388 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 389 390options: 391 --keep-remote Keep remote file when a conflict is encountered 392 --keep-local Keep local file when a conflict is encountered 393 --keep-largest Keep largest file when a conflict is encountered 394 --delete-extraneous Delete extraneous remote files 395 --dry-run Show what would have been transferred 396 --no-progress Hide progress 397 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 398 --chunksize <chunksize> Set chunk size in bytes, default: 8388608 399``` 400 401#### List file changes 402``` 403gdrive [global] changes [options] 404 405global: 406 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 407 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 408 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 409 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 410 411options: 412 -m, --max <maxChanges> Max changes to list, default: 100 413 --since <pageToken> Page token to start listing changes from 414 --now Get latest page token 415 --name-width <nameWidth> Width of name column, default: 40, minimum: 9, use 0 for full width 416 --no-header Dont print the header 417``` 418 419#### List file revisions 420``` 421gdrive [global] revision list [options] <fileId> 422 423global: 424 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 425 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 426 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 427 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 428 429options: 430 --name-width <nameWidth> Width of name column, default: 40, minimum: 9, use 0 for full width 431 --no-header Dont print the header 432 --bytes Size in bytes 433``` 434 435#### Download revision 436``` 437gdrive [global] revision download [options] <fileId> <revId> 438 439global: 440 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 441 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 442 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 443 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 444 445options: 446 -f, --force Overwrite existing file 447 --no-progress Hide progress 448 --stdout Write file content to stdout 449 --path <path> Download path 450 --timeout <timeout> Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300 451``` 452 453#### Delete file revision 454``` 455gdrive [global] revision delete <fileId> <revId> 456 457global: 458 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 459 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 460 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 461 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 462``` 463 464#### Upload and convert file to a google document, see 'about import' for available conversions 465``` 466gdrive [global] import [options] <path> 467 468global: 469 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 470 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 471 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 472 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 473 474options: 475 -p, --parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents 476 --no-progress Hide progress 477``` 478 479#### Export a google document 480``` 481gdrive [global] export [options] <fileId> 482 483global: 484 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 485 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 486 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 487 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 488 489options: 490 -f, --force Overwrite existing file 491 --mime <mime> Mime type of exported file 492 --print-mimes Print available mime types for given file 493``` 494 495#### Google drive metadata, quota usage 496``` 497gdrive [global] about [options] 498 499global: 500 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 501 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 502 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 503 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 504 505options: 506 --bytes Show size in bytes 507``` 508 509#### Show supported import formats 510``` 511gdrive [global] about import 512 513global: 514 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 515 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 516 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 517 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 518``` 519 520#### Show supported export formats 521``` 522gdrive [global] about export 523 524global: 525 -c, --config <configDir> Application path, default: /Users/<user>/.gdrive 526 --refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) 527 --access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) 528 --service-account <accountFile> Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir) 529``` 530 531 532## Examples 533#### List files 534``` 535$ gdrive list 536Id Name Type Size Created 5370B3X9GlR6EmbnZ3gyeGw4d3ozbUk drive-windows-x64.exe bin 6.6 MB 2015-07-18 16:43:58 5380B3X9GlR6EmbnTXlSc1FqV1dvSTQ drive-windows-386.exe bin 5.2 MB 2015-07-18 16:43:53 5390B3X9GlR6EmbnVjIzMDRqck1aekE drive-osx-x64 bin 6.5 MB 2015-07-18 16:43:50 5400B3X9GlR6EmbnbEpXdlhza25zT1U drive-osx-386 bin 5.2 MB 2015-07-18 16:43:41 5410B3X9GlR6Embnb095MGxEYmJhY2c drive-linux-x64 bin 6.5 MB 2015-07-18 16:43:38 542``` 543 544#### List largest files 545``` 546$ gdrive list --query "name contains 'gdrive'" --order "quotaBytesUsed desc" -m 3 547Id Name Type Size Created 5480B3X9GlR6EmbnZXpDRG1xblM2LTg gdrive-linux-mips64 bin 8.5 MB 2016-02-22 21:07:04 5490B3X9GlR6EmbnNW5CTV8xdFkxTjg gdrive-linux-mips64le bin 8.5 MB 2016-02-22 21:07:07 5500B3X9GlR6EmbnZ1NGS25FdEVlWEk gdrive-osx-x64 bin 8.3 MB 2016-02-21 20:22:13 551``` 552 553#### Upload file 554``` 555$ gdrive upload gdrive-osx-x64 556Uploading gdrive-osx-x64 557Uploaded 0B3X9GlR6EmbnZ1NGS25FdEVlWEk at 3.8 MB/s, total 8.3 MB 558``` 559 560#### Make directory 561``` 562$ gdrive mkdir gdrive-bin 563Directory 0B3X9GlR6EmbnY1RLVTk5VUtOVkk created 564``` 565 566#### Upload file to directory 567``` 568$ gdrive upload --parent 0B3X9GlR6EmbnY1RLVTk5VUtOVkk gdrive-osx-x64 569Uploading gdrive-osx-x64 570Uploaded 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E at 2.5 MB/s, total 8.3 MB 571``` 572 573#### Download file 574``` 575$ gdrive download 0B3X9GlR6EmbnZ1NGS25FdEVlWEk 576Downloading gdrive-osx-x64 -> gdrive-osx-x64 577Downloaded 0B3X9GlR6EmbnZ1NGS25FdEVlWEk at 8.3 MB/s, total 8.3 MB 578``` 579 580#### Share a file 581``` 582$ gdrive share 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E 583Granted reader permission to anyone 584``` 585 586#### Pipe content directly to google drive 587``` 588$ echo "Hello World" | gdrive upload - hello.txt 589Uploading hello.txt 590Uploaded 0B3X9GlR6EmbnaXVrOUpIcWlUS0E at 8.0 B/s, total 12.0 B 591``` 592 593#### Print file to stdout 594``` 595$ gdrive download --stdout 0B3X9GlR6EmbnaXVrOUpIcWlUS0E 596Hello World 597``` 598 599#### Get file info 600``` 601$ gdrive info 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E 602Id: 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E 603Name: gdrive-osx-x64 604Path: gdrive-bin/gdrive-osx-x64 605Mime: application/octet-stream 606Size: 8.3 MB 607Created: 2016-02-21 20:47:04 608Modified: 2016-02-21 20:47:04 609Md5sum: b607f29231a3b2d16098c4212516470f 610Shared: True 611Parents: 0B3X9GlR6EmbnY1RLVTk5VUtOVkk 612ViewUrl: https://drive.google.com/file/d/0B3X9GlR6EmbnNTk0SkV0bm5Hd0E/view?usp=drivesdk 613DownloadUrl: https://docs.google.com/uc?id=0B3X9GlR6EmbnNTk0SkV0bm5Hd0E&export=download 614``` 615 616#### Update file (create new revision) 617``` 618$ gdrive update 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E gdrive-osx-x64 619Uploading gdrive-osx-x64 620Updated 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E at 2.0 MB/s, total 8.3 MB 621``` 622 623#### List file revisions 624``` 625$ gdrive revision list 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E 626Id Name Size Modified KeepForever 6270B3X9GlR6EmbnOFlHSTZQNWJWMGN2ckZucC9VaEUwczV1cUNrPQ gdrive-osx-x64 8.3 MB 2016-02-21 20:47:04 False 6280B3X9GlR6EmbndVEwMlZCUldGWUlPb2lTS25rOFo1L2t6c2ZVPQ gdrive-osx-x64 8.3 MB 2016-02-21 21:12:09 False 629``` 630 631#### Download revision 632``` 633$ gdrive revision download 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E 0B3X9GlR6EmbnOFlHSTZQNWJWMGN2ckZucC9VaEUwczV1cUNrPQ 634Downloading gdrive-osx-x64 -> gdrive-osx-x64 635Download complete, rate: 8.3 MB/s, total size: 8.3 MB 636``` 637 638#### Export google doc as docx 639``` 640$ gdrive export --mime application/vnd.openxmlformats-officedocument.wordprocessingml.document 1Kt5A8X7X2RQrEi5t6Y9W1LayRc4hyrFiG63y2dIJEvk 641Exported 'foo.docx' with mime type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' 642``` 643 644#### Import csv as google spreadsheet 645``` 646$ gdrive import foo.csv 647Imported 1mTl3DjIvap4tpTX_oMkDcbDT8ShtiGJRlozTfkXpeko with mime type: 'application/vnd.google-apps.spreadsheet' 648``` 649 650#### Syncing directory to drive 651``` 652# Create directory on drive 653$ gdrive mkdir drive-bin 654Directory 0B3X9GlR6EmbnOEd6cEh6bU9XZWM created 655 656# Sync to drive 657$ gdrive sync upload _release/bin 0B3X9GlR6EmbnOEd6cEh6bU9XZWM 658Starting sync... 659Collecting local and remote file information... 660Found 32 local files and 0 remote files 661 6626 remote directories are missing 663[0001/0006] Creating directory drive-bin/bsd 664[0002/0006] Creating directory drive-bin/linux 665[0003/0006] Creating directory drive-bin/osx 666[0004/0006] Creating directory drive-bin/plan9 667[0005/0006] Creating directory drive-bin/solaris 668[0006/0006] Creating directory drive-bin/windows 669 67026 remote files are missing 671[0001/0026] Uploading bsd/gdrive-dragonfly-x64 -> drive-bin/bsd/gdrive-dragonfly-x64 672[0002/0026] Uploading bsd/gdrive-freebsd-386 -> drive-bin/bsd/gdrive-freebsd-386 673[0003/0026] Uploading bsd/gdrive-freebsd-arm -> drive-bin/bsd/gdrive-freebsd-arm 674[0004/0026] Uploading bsd/gdrive-freebsd-x64 -> drive-bin/bsd/gdrive-freebsd-x64 675[0005/0026] Uploading bsd/gdrive-netbsd-386 -> drive-bin/bsd/gdrive-netbsd-386 676[0006/0026] Uploading bsd/gdrive-netbsd-arm -> drive-bin/bsd/gdrive-netbsd-arm 677[0007/0026] Uploading bsd/gdrive-netbsd-x64 -> drive-bin/bsd/gdrive-netbsd-x64 678[0008/0026] Uploading bsd/gdrive-openbsd-386 -> drive-bin/bsd/gdrive-openbsd-386 679[0009/0026] Uploading bsd/gdrive-openbsd-arm -> drive-bin/bsd/gdrive-openbsd-arm 680[0010/0026] Uploading bsd/gdrive-openbsd-x64 -> drive-bin/bsd/gdrive-openbsd-x64 681[0011/0026] Uploading linux/gdrive-linux-386 -> drive-bin/linux/gdrive-linux-386 682[0012/0026] Uploading linux/gdrive-linux-arm -> drive-bin/linux/gdrive-linux-arm 683[0013/0026] Uploading linux/gdrive-linux-arm64 -> drive-bin/linux/gdrive-linux-arm64 684[0014/0026] Uploading linux/gdrive-linux-mips64 -> drive-bin/linux/gdrive-linux-mips64 685[0015/0026] Uploading linux/gdrive-linux-mips64le -> drive-bin/linux/gdrive-linux-mips64le 686[0016/0026] Uploading linux/gdrive-linux-ppc64 -> drive-bin/linux/gdrive-linux-ppc64 687[0017/0026] Uploading linux/gdrive-linux-ppc64le -> drive-bin/linux/gdrive-linux-ppc64le 688[0018/0026] Uploading linux/gdrive-linux-x64 -> drive-bin/linux/gdrive-linux-x64 689[0019/0026] Uploading osx/gdrive-osx-386 -> drive-bin/osx/gdrive-osx-386 690[0020/0026] Uploading osx/gdrive-osx-arm -> drive-bin/osx/gdrive-osx-arm 691[0021/0026] Uploading osx/gdrive-osx-x64 -> drive-bin/osx/gdrive-osx-x64 692[0022/0026] Uploading plan9/gdrive-plan9-386 -> drive-bin/plan9/gdrive-plan9-386 693[0023/0026] Uploading plan9/gdrive-plan9-x64 -> drive-bin/plan9/gdrive-plan9-x64 694[0024/0026] Uploading solaris/gdrive-solaris-x64 -> drive-bin/solaris/gdrive-solaris-x64 695[0025/0026] Uploading windows/gdrive-windows-386.exe -> drive-bin/windows/gdrive-windows-386.exe 696[0026/0026] Uploading windows/gdrive-windows-x64.exe -> drive-bin/windows/gdrive-windows-x64.exe 697Sync finished in 1m18.891946279s 698 699# Add new local file 700$ echo "google drive binaries" > _release/bin/readme.txt 701 702# Sync again 703$ gdrive sync upload _release/bin 0B3X9GlR6EmbnOEd6cEh6bU9XZWM 704Starting sync... 705Collecting local and remote file information... 706Found 33 local files and 32 remote files 707 7081 remote files are missing 709[0001/0001] Uploading readme.txt -> drive-bin/readme.txt 710Sync finished in 2.201339535s 711 712# Modify local file 713$ echo "for all platforms" >> _release/bin/readme.txt 714 715# Sync again 716$ gdrive sync upload _release/bin 0B3X9GlR6EmbnOEd6cEh6bU9XZWM 717Starting sync... 718Collecting local and remote file information... 719Found 33 local files and 33 remote files 720 7211 local files has changed 722[0001/0001] Updating readme.txt -> drive-bin/readme.txt 723Sync finished in 1.890244258s 724``` 725 726#### List content of sync directory 727``` 728$ gdrive sync content 0B3X9GlR6EmbnOEd6cEh6bU9XZWM 729Id Path Type Size Modified 7300B3X9GlR6EmbnMldxMFV1UGVMTlE bsd dir 2016-02-21 22:54:00 7310B3X9GlR6EmbnM05sQ3hVUnJnOXc bsd/gdrive-dragonfly-x64 bin 7.8 MB 2016-02-21 22:54:14 7320B3X9GlR6EmbnVy1KXzA4dlU5RVE bsd/gdrive-freebsd-386 bin 6.1 MB 2016-02-21 22:54:18 7330B3X9GlR6Embnb29QQkFtSlRiZnc bsd/gdrive-freebsd-arm bin 6.1 MB 2016-02-21 22:54:20 7340B3X9GlR6EmbnMkFQYVpSaHhHTXM bsd/gdrive-freebsd-x64 bin 7.8 MB 2016-02-21 22:54:23 7350B3X9GlR6EmbnVmJRMl9hUDloVU0 bsd/gdrive-netbsd-386 bin 6.1 MB 2016-02-21 22:54:25 7360B3X9GlR6EmbnLVlTZWpxOEF4Q2s bsd/gdrive-netbsd-arm bin 6.1 MB 2016-02-21 22:54:28 7370B3X9GlR6EmbnOENUZmh3anJmNG8 bsd/gdrive-netbsd-x64 bin 7.8 MB 2016-02-21 22:54:30 7380B3X9GlR6EmbnWTRoQ2ZVQXRfQlU bsd/gdrive-openbsd-386 bin 6.1 MB 2016-02-21 22:54:32 7390B3X9GlR6EmbncEtlN3ZuQ0VUWms bsd/gdrive-openbsd-arm bin 6.1 MB 2016-02-21 22:54:35 7400B3X9GlR6EmbnMlFLY1ptNEFyZWc bsd/gdrive-openbsd-x64 bin 7.8 MB 2016-02-21 22:54:38 7410B3X9GlR6EmbncGtSajQyNzloVEE linux dir 2016-02-21 22:54:01 7420B3X9GlR6EmbnMWVudkJmb1NZdmM linux/gdrive-linux-386 bin 6.1 MB 2016-02-21 22:54:40 7430B3X9GlR6Embnbnpla1R2VHV5T2M linux/gdrive-linux-arm bin 6.1 MB 2016-02-21 22:54:42 7440B3X9GlR6EmbnM0s2cU1YWkNJSjA linux/gdrive-linux-arm64 bin 7.7 MB 2016-02-21 22:54:45 7450B3X9GlR6EmbnNU9NNi1TdDc4S2c linux/gdrive-linux-mips64 bin 8.5 MB 2016-02-21 22:54:47 7460B3X9GlR6EmbnSmdQNjRKZ2dWV1U linux/gdrive-linux-mips64le bin 8.5 MB 2016-02-21 22:54:50 7470B3X9GlR6EmbnS0g0OVgxMHY5Z3c linux/gdrive-linux-ppc64 bin 7.8 MB 2016-02-21 22:54:52 7480B3X9GlR6EmbneVp6ZXRpR3FhWlU linux/gdrive-linux-ppc64le bin 7.8 MB 2016-02-21 22:54:54 7490B3X9GlR6EmbnczdJT195dFVxdU0 linux/gdrive-linux-x64 bin 7.8 MB 2016-02-21 22:54:57 7500B3X9GlR6EmbnTXZXeDRnSDdVS1E osx dir 2016-02-21 22:54:02 7510B3X9GlR6EmbnWnRheXJNR0pUMU0 osx/gdrive-osx-386 bin 6.6 MB 2016-02-21 22:54:59 7520B3X9GlR6EmbnRzNqMWFXdDR1Rms osx/gdrive-osx-arm bin 6.6 MB 2016-02-21 22:55:01 7530B3X9GlR6EmbnaDlVWTZDd0JIeEU osx/gdrive-osx-x64 bin 8.3 MB 2016-02-21 22:55:04 7540B3X9GlR6EmbnWW84UFBvbHlURXM plan9 dir 2016-02-21 22:54:02 7550B3X9GlR6EmbnTmc0a2RNdDZDRUU plan9/gdrive-plan9-386 bin 5.8 MB 2016-02-21 22:55:07 7560B3X9GlR6EmbnT1pYZ2p4Sk9FVFk plan9/gdrive-plan9-x64 bin 7.4 MB 2016-02-21 22:55:10 7570B3X9GlR6EmbnbnZnXzlYVHoxdk0 readme.txt bin 40.0 B 2016-02-21 22:59:56 7580B3X9GlR6EmbnSWF1QUlta3RnaGc solaris dir 2016-02-21 22:54:03 7590B3X9GlR6EmbnaWFOV0YxSGs5Znc solaris/gdrive-solaris-x64 bin 7.7 MB 2016-02-21 22:55:13 7600B3X9GlR6EmbnNE5ySkEzbWQ4Qms windows dir 2016-02-21 22:54:03 7610B3X9GlR6EmbnX1RIT2w1TWZYWFU windows/gdrive-windows-386.exe bin 6.1 MB 2016-02-21 22:55:15 7620B3X9GlR6EmbndmVMU05POGRPS3c windows/gdrive-windows-x64.exe bin 7.8 MB 2016-02-21 22:55:18 763``` 764