Skip to content

kunkunlin1221/UpDownGDrive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UpDownGDrive

This repository provides a tool for uploading and downloading files to and from Google Drive. It uses personal credentials to access both individual and shared drives, allowing seamless transfer of folders and files.

Installation

pip install -r requirements.txt

Prepare credentials

  1. Go to Google Cloud Console
  2. Create a new project
  3. Go to the project
  4. Go to the APIs & Services -> enable Google Drive API
  5. Go to the Credentials -> create credentials -> Build on oAuth2.0 -> Desktop app
  6. Download the credentials json and put it in the root of the project as credentials.json

Usage

Upload a file

file_path="path/to/file"
folder_id="folder_id"
credentials_file="path/to/credentials.json"
ipython -- src/upload.py \
    --file_path $file_path \
    --folder_id $folder_id \
    --credentials_file $credentials_file

Upload a folder

folder="path/to/folder"
mother_folder_id="mother_folder_id"
# if you want to upload inside a existing folder, you need to give mother folder id
credentials_file="path/to/credentials.json"
ipython -- src/upload_folder.py \
    --folder $folder \
    --mother_folder_id $mother_folder_id \
    --credentials_file $credentials_file

Download a file

file_id="file_id"
dst_path="path/to/save"
credentials_file="path/to/credentials.json"
ipython -- src/download.py \
    --file_id $file_id \
    --dst_path $dst_path \
    --credentials_file $credentials_file

Download a folder

folder_id="folder_id"
dst_folder="path/to/save"
credentials_file="path/to/credentials.json"
scan_size=1000
ipython -- src/download_folder.py \
    --folder_id $folder_id \
    --dst_folder $dst_folder \
    --credentials_file $credentials_file \
    --scan_size $scan_size

About

Tool for uploading and downloading files to and from Google Drive.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages