Cara Upload dan Download File di Google Drive dengan Terminal Linux

Kamis, 22 November 2018

Cara Upload dan Download File di Google Drive dengan Terminal Linux - Google Drive merupakan salahsatu penyimpanan file cloud yang cukup populer. Namun sayangnya tidak ada client resmi yang tersedia di Linux sehingga kita bisa memanajemen file di akun Google Drive kita dengan terminal linux. Beruntung disini ada salahsatu project di GitHub yang sangat berguna untuk melakukan hal tersebut.

Gdrive yang dikembangkan oleh Petter Rasmussen adalah tool yang ditujukan untuk manajemen file maupun folder di Google Drive.

Instalasi

Pertama, download file yang sudah dicompile melalui alamat berikut:


Ada banyak link download yang disediakan. Silahkan pilih yang paling sesuai. Disini saya pilih gdrive-linux-x64 karena itu yang sesuai dengan sistem yang saya pakai.
wget "https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA&export=download" -O gdrive

Beri hak akses eksekusi lalu install ke direktori /bin.
chmod +x gdrive
sudo install gdrive /usr/local/bin/gdrive

Selanjutnya, kita jalankan salahsatu perintah untuk inisialisasi agar kita bisa menghubungkan akun Google Drive kita dengan tool gdrive.
gdrive list

Copy url tersebut ke browser lalu login dengan akun Google kalian untuk mendapatkan kode verifikasinya.


Selanjutnya masukkan kode tersebut ke terminal.

Berikut perintah yang dapat digunakan di tool gdrive.
yuyudhn@linuxsec:~$ gdrive help
gdrive usage:

gdrive [global] list [options]                                 List files
gdrive [global] download [options] <fileId>                    Download file or directory
gdrive [global] download query [options] <query>               Download all files and directories matching query
gdrive [global] upload [options] <path>                        Upload file or directory
gdrive [global] upload - [options] <name>                      Upload file from stdin
gdrive [global] update [options] <fileId> <path>               Update file, this creates a new revision of the file
gdrive [global] info [options] <fileId>                        Show file info
gdrive [global] mkdir [options] <name>                         Create directory
gdrive [global] share [options] <fileId>                       Share file or directory
gdrive [global] share list <fileId>                            List files permissions
gdrive [global] share revoke <fileId> <permissionId>           Revoke permission
gdrive [global] delete [options] <fileId>                      Delete file or directory
gdrive [global] sync list [options]                            List all syncable directories on drive
gdrive [global] sync content [options] <fileId>                List content of syncable directory
gdrive [global] sync download [options] <fileId> <path>        Sync drive directory to local directory
gdrive [global] sync upload [options] <path> <fileId>          Sync local directory to drive
gdrive [global] changes [options]                              List file changes
gdrive [global] revision list [options] <fileId>               List file revisions
gdrive [global] revision download [options] <fileId> <revId>   Download revision
gdrive [global] revision delete <fileId> <revId>               Delete file revision
gdrive [global] import [options] <path>                        Upload and convert file to a google document, see 'about import' for available conversions
gdrive [global] export [options] <fileId>                      Export a google document
gdrive [global] about [options]                                Google drive metadata, quota usage
gdrive [global] about import                                   Show supported import formats
gdrive [global] about export                                   Show supported export formats
gdrive version                                                 Print application version
gdrive help                                                    Print help
gdrive help <command>                                          Print command help
gdrive help <command> <subcommand>                             Print subcommand help

Oke berikut beberapa parameter untuk list file.
yuyudhn@linuxsec:~$ gdrive help list
List files
gdrive [global] list [options]

global:
  -c, --config <configDir>         Application path, default: /home/yuyudhn/.gdrive
  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)
  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)

options:
  -m, --max <maxFiles>       Max files to list, default: 30
  -q, --query <query>        Default query: "trashed = false and 'me' in owners". See https://developers.google.com/drive/search-parameters
  --order <sortOrder>        Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy
  --name-width <nameWidth>   Width of name column, default: 40, minimum: 9, use 0 for full width
  --absolute                 Show absolute path to file (will only show path from first parent)
  --no-header                Dont print the header
  --bytes                    Size in bytes

Download File atau Direktori

yuyudhn@linuxsec:~$ gdrive help download
Download file or directory
gdrive [global] download [options] <fileId>

global:
  -c, --config <configDir>         Application path, default: /home/yuyudhn/.gdrive
  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)
  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)

options:
  -f, --force           Overwrite existing file
  -r, --recursive       Download directory recursively, documents will be skipped
  --path <path>         Download path
  --delete              Delete remote file when download is successful
  --no-progress         Hide progress
  --stdout              Write file content to stdout
  --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

Upload File maupun Direktori

yuyudhn@linuxsec:~$ gdrive help upload
Upload file or directory
gdrive [global] upload [options] <path>

global:
  -c, --config <configDir>         Application path, default: /home/yuyudhn/.gdrive
  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)
  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)

options:
  -r, --recursive           Upload directory recursively
  -p, --parent <parent>     Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents
  --name <name>             Filename
  --no-progress             Hide progress
  --mime <mime>             Force mime type
  --share                   Share file
  --delete                  Delete local file when upload is successful
  --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
  --chunksize <chunksize>   Set chunk size in bytes, default: 8388608


Untuk perintah lain bisa kalian cek sendiri menggunakan perintah help.

Artikel Terkait GNU/Linux ,Terminal ,Utilities