Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frederikwillersinn/google_drive_data_transfer
Python Package Development | Google Drive File Transfer | PyDrive
https://github.com/frederikwillersinn/google_drive_data_transfer
Last synced: 3 months ago
JSON representation
Python Package Development | Google Drive File Transfer | PyDrive
- Host: GitHub
- URL: https://github.com/frederikwillersinn/google_drive_data_transfer
- Owner: frederikwillersinn
- License: mit
- Created: 2022-03-21T08:30:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T11:53:00.000Z (over 2 years ago)
- Last Synced: 2024-07-06T05:40:06.519Z (4 months ago)
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# google_drive_data_transfer
google_drive_data_transfer is a simple Python package which is built based on
[PyDrive2](https://docs.iterative.ai/PyDrive2/) and allows basic file management on
Google Drive.## Features of google_drive_data_transfer
The package contains the following features:
### 1. List all files on Google Drive
By default, the list contains all files from the "My Drive" directory.
Options:
- list files from any other folder on Google Drive
- include metadata, such as the file ID, the file link, or the file type### 2. Upload a file to Google Drive
By default, the file gets uploaded to the "My Drive" directory.
Options:
- upload the file with a different name than the local one
- upload a file into any other folder on Google Drive### 3. Download a file from Google Drive
By default, the file gets downloaded from the "My Drive" directory. Drive Documents,
Drive Sheets or Drive Presentations will receive the appropriate suffix (.docx, .xlsx,
.pptx) automatically.Options:
- download the file with a different name than the remote one
- download a file from any other folder on Google Drive### 4. Remove a file from Google Drive
By default, the file gets removed from the "My Drive" directory.
Options:
- remove a file from any other a folder on Google Drive## How to install
You can install google_drive_data_transfer with a regular pip command.
`$ pip install google_drive_data_transfer`
## Quickstart
1. Go to the [APIs Console](https://console.developers.google.com/iam-admin/projects)
and make your own project.
2. Search for 'Google Drive API', select the entry, and click 'Enable'.
3. Select 'Credentials' from the left menu, click 'Create Credentials', select
'OAuth client ID'.
4. Now, the product name and consent screen need to be set -> click
'Configure consent screen' and follow the instructions. Once finished:
5. Select 'Application type' to be Web application.
6. Enter an appropriate name.
7. Input http://localhost:8080/ for 'Authorized redirect URIs'.
8. Click 'Create'.
9. Click 'Download JSON' on the right side of Client ID to download
`client_secret_.json`.
10. The downloaded file has all authentication information of your application.
Rename the file to `client_secrets.json` and place it in your working directory.
The `auth_dir` attribute you need to provide when instantiating `GoogleDriveData` class
must be the directory which contains the `client_secrets.json`. When you instantiate and
object of the `GoogleDriveData` class for the first time, you will see a web browser
asking you for authentication. Click 'Accept', and you are done with authentication.
This needs to be done only once.Parts of the Quickstart documentation were taken from the
[PyDrive2 documentation](https://docs.iterative.ai/PyDrive2/quickstart/#authentication).## Sample code
### Download a file from Google Drive:
Input:
````python
from google_drive_data_transfer.GoogleDriveDataTransfer import GoogleDriveDataTransferauth_dir = 'path_to_client_secrets'
drive = GoogleDriveDataTransfer(auth_dir)
drive.download_file(file_name="file.csv")
````Logged output:
````text
- INFO - Found file 'file.csv' in folder 'root' on Google Drive.
- INFO - Downloading 'file.csv' from Google Drive as 'file.csv'...
- INFO - Done.
````