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-uploader/

功能

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

安裝

您可以通過 Python 的包管理工具 Poetry 來安裝 Google Drive Uploader:

poetry add bdd-google-drive-helperer

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

pip install bdd-google-drive-helperer

配置

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

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

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

    uploader = GoogleDriveUploader(credentials_json="path/to/your/credentials.json")
    explorer = GoogleDriveExplorer(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)

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.0.post2.tar.gz (4.9 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.0.post2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file bdd_google_drive_helper-0.1.0.post2.tar.gz.

File metadata

  • Download URL: bdd_google_drive_helper-0.1.0.post2.tar.gz
  • Upload date:
  • Size: 4.9 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.0.post2.tar.gz
Algorithm Hash digest
SHA256 a38718240ae175b5af15c4f8bb846dde2a3212f7a88b212b8aa81e1a0f6d3184
MD5 5059a41ede6d42b3f64005064520c602
BLAKE2b-256 b409f2fb3718c7b3e9c50ee9dbf3482457f26e3134b0434fa9c1be65966e6b37

See more details on using hashes here.

File details

Details for the file bdd_google_drive_helper-0.1.0.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for bdd_google_drive_helper-0.1.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 5e6aa8dd6c8c2cd1d23a8ceaa8368c4846dcbe2e43cb49e7a5469e446989ce59
MD5 c2b194c1d211447ea4ef482acceb9939
BLAKE2b-256 c9df9b0c72986bb4c922853446143377384461609aeff2222c04314418f73cb0

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