ອັບໂຫລດໄຟລ Google Drive ໂດຍຜ່ານ command line Linux

Outhai SAIOUDOM
LaoITDev
Published in
2 min readJan 3, 2018

ບັນທຶກງ່າຍໆ ກັນລືມ ພໍດີລຸງໄປເຫັນວິທີການ ສົ່ງໄຟລ ເຂົ້າໄປໃນ Google Drive ດ້ວຍຄຳສັ່ງ linux ( ເອົາໄວ້ແບັກອັບໄຟລໄວ້ Gdrive)

ກະຄຳສັ່ງສັ້ນໆຕາມນີ້ເລີຍ:

ສັ່ງດາວໂຫລດ gdrive for linux

ຈາກ https://github.com/prasmussen/gdrive#downloads

ຫລື ສັ່ງ

wget https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=downloadmv uc\?id\=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrivechmod +x gdriveinstall gdrive /usr/local/bin/gdrive

ແລ້ວສັ່ງ list ເບິ່ງ

gdrive list

ຈາກນັ້ນມັນຈະໃຫ້ໄປ ເອົາ token ຕາມລິ້ງ ໂຕຢ່າງ

Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=ປປປປປ-7n0vf5akປປປປ6o2fjinrecpdoe99eg.apps.googleusercontent.com&redirect_uri=uປປປປປresponse_type=code&scope=https%3A%2F%ປປປປປປປປປປປປປປປປປປປ

ຫລັງຈາກໄດ້ token ແລ້ວກໍເອົາກັບມາວາງໄວ້ບ່ອນນີ້ແລ້ວກໍກົດ enter

Enter verification code: 4/Fgxxxxxxxx4-rzFUySxxxxxxxxxxxngUih_xxxxxxxxxxxxx

ຫລັງຈາກສຳເລັດແລ້ວກໍ ໃຫ້ສັ່ງ ອັບໂຫລດດັ່ງນີ້

gdrive upload -r ໂຟນເດີ້ປາຍທາງ

gdrive upload -r /home/admin/backups/BackupDec2017/

ຄຳສັ່ງອັບໂຫລດ

gdrive [global] upload [options] <path>

global:
-c, --config <configDir> Application path, default: /Users/<user>/.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
--chunksize <chunksize> Set chunk size in bytes, default: 8388608

ຄຳສັ່ງດາວໂຫລດ

gdrive [global] download [options] 

global:
-c, --config Application path, default: /Users//.gdrive
--refresh-token Oauth refresh token used to get access token (for advanced users)
--access-token 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 Download path
--delete Delete remote file when download is successful
--no-progress Hide progress
--stdout Write file content to stdout

ຄຳສັ່ງ List file

gdrive [global] list [options]

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

options:
-m, --max Max files to list, default: 30
-q, --query Default query: "trashed = false and 'me' in owners". See https://developers.google.com/drive/search-parameters
--order Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy
--name-width 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

ຄຳສັ່ງ Share

gdrive [global] share [options] 

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

options:
--role Share role: owner/writer/commenter/reader, default: reader
--type Share type: user/group/domain/anyone, default: anyone
--email The email address of the user or group to share the file with. Requires 'user' or 'group' as type
--discoverable Make file discoverable by search engines
--revoke Delete all sharing permissions (owner roles will be skipped)

--

--