Skip to main content

A simple Google Drive file uploader tool.

Project description

Google Drive Uploader

Google Drive Uploader 是一個簡單的工具,用於將文件上傳到 Google Drive。這個工具提供了一個簡單的 Python API,可以方便地集成到您的自動化腳本和應用程序中。

PyPI url

https://pypi.org/project/bdd-google-drive-helper/

功能

  • 身份驗證管理
  • 列出和搜索 Google Drive 上的共用雲端硬碟
  • 根據資料夾路徑查找特定資料夾的 ID
  • 將檔案上傳到指定的 Google Drive 資料夾
  • 探索和管理 Google Drive 的內容,包括列出所有資料夾
  • 根據日期刪除指定資料夾中的檔案

安裝

您可以通過 Python 的包管理工具 Poetry 來安裝 Google Drive Uploader:```bash poetry add bdd-google-drive-helperer


或者,如果您使用的是 pip,請先確保您的環境中安裝了 Poetry,然後運行以下命令:

```bash
pip install bdd-google-drive-helperer

配置

  • 請確保您已經在本地配置了 credentials.json 文件,並且您的 Google API 應用程序有足夠的權限來訪問 Google Drive。

  • 若還沒有'credentials.json' 文件:

    • 至Google Cloud Console 開啟新的專案
    • 啟用Google Drive API
    • 創建憑證 -> 電腦端應用程式 -> 下載憑證
    • 將下載後的憑證移至專案的根目錄
  • 請在本地端進行初始化時提供 credentials_jsoncredentials_pickle 來自訂您的身份驗證憑證存放路徑:

    uploader = GoogleDriveUploader(credentials_json="path/to/your/credentials.json")
    explorer = GoogleDriveExplorer(credentials_json="path/to/your/credentials.json")
    deleter = GoogleDriveDeleter(credentials_json="path/to/your/credentials.json")
    
  • 首次初始化時,會在Terminal生成一個連結,直接打開該連結進行驗證,認證完成後,就可以獲得可復用的 token.pkl

  • 獲得此token.pkl後就可以使用此檔案在任何環境進行使用和開發。

快速入門

以下是一個如何使用 Google Drive Uploader 的簡單範例:

from google_drive_helper.google_drive_uploader import GoogleDriveUploader

# 初始化 uploader
uploader = GoogleDriveUploader()

# 上傳檔案到指定的 Google Drive 資料夾
drive_name = "YourDriveName"
drive_folder_path = "path/to/your/google drive folder"
upload_file_path = "path/to/your/local_file.txt"
uploader.upload_to_drive(drive_name, drive_folder_path, upload_file_path)

以下是如何使用 Google Drive Explorer 來列出和探索 Google Drive 的範例:

from google_drive_helper.google_drive_explorer import GoogleDriveExplorer

# 初始化 explorer
explorer = GoogleDriveExplorer()

# 列出所有共用雲端硬碟或查找特定資料夾
drive_name = "YourDriveName"
explorer.find_folder(drive_name)

以下是如何使用 Google Drive Explorer 來確認查找資料夾是否存在

from google_drive_helper.google_drive_explorer import GoogleDriveExplorer

# 初始化 explorer
explorer = GoogleDriveExplorer()

# 列出所有共用雲端硬碟或查找特定資料夾
drive_name = "YourDriveName"
folder_to_find = "folder/path/you/want/to/find"
explorer.find_folder(drive_name,folder_to_find)

以下是如何使用 Google Drive Deleter 來刪除指定資料夾中的檔案

from google_drive_helper.google_drive_deleter import GoogleDriveDeleter

# 初始化 deleter
deleter = GoogleDriveDeleter()

# 刪除指定資料夾中指定日期的檔案
drive_name = "YourDriveName"
folder_path = "path/to/your/google drive folder"
target_date = "YYYY-MM-DD"
deleter.delete_files_by_date(drive_name, folder_path, target_date)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bdd_google_drive_helper-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bdd_google_drive_helper-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file bdd_google_drive_helper-0.1.1.tar.gz.

File metadata

  • Download URL: bdd_google_drive_helper-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for bdd_google_drive_helper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9e6804ac3c5048e7f8687dc28cf3dfd5d7c5e3fd7901fb0a3953f214a6b41a78
MD5 764443f5a8a50d4c0aa5ca20bf41843d
BLAKE2b-256 ac14038b99bb8878600d8487ab4c88b273e8bede1d83ac7896192161a609ec97

See more details on using hashes here.

File details

Details for the file bdd_google_drive_helper-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bdd_google_drive_helper-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for bdd_google_drive_helper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f2ce3a26e97e81e8ca31d9732660e94dda40f3b5819de7f46e43b2e33a3143d
MD5 8cd2899ce5a53dcfb7fcfd1420b05581
BLAKE2b-256 0345aff95fd12b0df2e2191b97fbc06d7fef9d0f8dd3a46c9909b5bcef53e10d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page