1139 字
6 分鐘
google Drive 雲端硬碟 搭配workers 建立Index

介紹#

可將你的 google drive 內檔案在 workers 上建立 index,可以看一下作者的 Demo:oss.achirou.workers.dev/(在新分頁開啟),可以線上觀看影片,看圖片,也可以下載任何檔案,index 網頁是可以設定密碼也不用怕被陌生人看到,試試看如何使用,不懂程式語言也可以手把手輕鬆做出來。

設定方法#

請先註冊 dash.cloudflare.com/sign-up/workers(在新分頁開啟),右上可選擇語言

免費方案,每天可請求 10 萬筆

使用 rclone 取得 refresh_token#

  • 需要使用 rclone 取得個人的 refresh_token、client_id、client_secret

  • 使用 colab 安裝 rclone

    colab.research.google.com/github/kobojp/aria2-colab/blob/master/install_rclone.ipynb(在新分頁開啟)

    設定說明

    Terminal window
    No remotes found - make a new one
    n) New remote
    s) Set configuration password
    q) Quit config
    n/s/q> n # 輸入n 建立remote
    name> gd
    Type of storage to configure.
    Enter a string value. Press Enter for the default ("").
    Choose a number from below, or type in your own value
    1 / 1Fichier
    \ "fichier"
    2 / Alias for an existing remote
    \ "alias"
    3 / Amazon Drive
    \ "amazon cloud drive"
    4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
    \ "s3"
    5 / Backblaze B2
    \ "b2"
    6 / Box
    \ "box"
    7 / Cache a remote
    \ "cache"
    8 / Citrix Sharefile
    \ "sharefile"
    9 / Dropbox
    \ "dropbox"
    10 / Encrypt/Decrypt a remote
    \ "crypt"
    11 / FTP Connection
    \ "ftp"
    12 / Google Cloud Storage (this is not Google Drive)
    \ "google cloud storage"
    13 / Google Drive
    \ "drive"
    14 / Google Photos
    \ "google photos"
    15 / Hubic
    \ "hubic"
    16 / In memory object storage system.
    \ "memory"
    17 / Jottacloud
    \ "jottacloud"
    18 / Koofr
    \ "koofr"
    19 / Local Disk
    \ "local"
    20 / Mail.ru Cloud
    \ "mailru"
    21 / Mega
    \ "mega"
    22 / Microsoft Azure Blob Storage
    \ "azureblob"
    23 / Microsoft OneDrive
    \ "onedrive"
    24 / OpenDrive
    \ "opendrive"
    25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
    \ "swift"
    26 / Pcloud
    \ "pcloud"
    27 / Put.io
    \ "putio"
    28 / QingCloud Object Storage
    \ "qingstor"
    29 / SSH/SFTP Connection
    \ "sftp"
    30 / Sugarsync
    \ "sugarsync"
    31 / Tardigrade Decentralized Cloud Storage
    \ "tardigrade"
    32 / Transparently chunk/split large files
    \ "chunker"
    33 / Union merges the contents of several upstream fs
    \ "union"
    34 / Webdav
    \ "webdav"
    35 / Yandex Disk
    \ "yandex"
    36 / http Connection
    \ "http"
    37 / premiumize.me
    \ "premiumizeme"
    38 / seafile
    \ "seafile"
    Storage> 13 # 輸入 13
    ** See help for drive backend at: https://rclone.org/drive/ **
    OAuth Client Id
    Leave blank normally.
    Enter a string value. Press Enter for the default ("").
    client_id> # 留空
    OAuth Client Secret
    Leave blank normally.
    Enter a string value. Press Enter for the default ("").
    client_secret> # 留空
    Scope that rclone should use when requesting access from drive.
    Enter a string value. Press Enter for the default ("").
    Choose a number from below, or type in your own value
    1 / Full access all files, excluding Application Data Folder.
    \ "drive"
    2 / Read-only access to file metadata and file contents.
    \ "drive.readonly"
    / Access to files created by rclone only.
    3 | These are visible in the drive website.
    | File authorization is revoked when the user deauthorizes the app.
    \ "drive.file"
    / Allows read and write access to the Application Data folder.
    4 | This is not visible in the drive website.
    \ "drive.appfolder"
    / Allows read-only access to file metadata but
    5 | does not allow any access to read or download file content.
    \ "drive.metadata.readonly"
    scope> 1 # 輸入 1
    ID of the root folder
    Leave blank normally.
    Fill in to access "Computers" folders (see docs), or for rclone to use
    a non root folder as its starting point.
    Enter a string value. Press Enter for the default ("").
    root_folder_id>
    Service Account Credentials JSON file path
    Leave blank normally.
    Needed only if you want use SA instead of interactive login.
    Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
    Enter a string value. Press Enter for the default ("").
    service_account_file> # 留空
    Edit advanced config? (y/n)
    y) Yes
    n) No (default)
    y/n> n # 輸入 n
    Remote config
    Use auto config?
    * Say Y if not sure
    * Say N if you are working on a remote or headless machine
    y) Yes (default)
    n) No
    y/n> n # 輸入n 如果輸入Y會無法取得授權
    Please go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=CCcaa&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=2tcyRHXyFQr1zZkmGcwYMw
    Log in and authorize rclone for access
    Enter verification code> 4/5wFubkoEF4ivZfYC3B8mbxPL8tRbKv4ZO8dKPqizl1nzbm2dQgfrtKg
    Configure this as a team drive?
    y) Yes
    n) No (default)
    y/n> y # 輸入 Y
    Fetching team drive list...
    Choose a number from below, or type in your own value
    1 / share
    \ "0ANz2seq1rrO59PVA"
    Enter a Team Drive ID> 1 # 輸入 1 或選擇你要的team drive
    --------------------
    [gd] # 以下是設定檔資訊,請複製 refresh_token
    type = drive
    scope = drive
    token = {"access_token":"","token_type":"Bearer","refresh_token":"...","expiry":"2020"}
    team_drive = 0ANz2seq1rrO59PVA
    root_folder_id =
    --------------------
    y) Yes this is OK (default)
    e) Edit this remote
    d) Delete this remote
    y/e/d> y # 輸入y
    Current remotes:
    Name Type
    ==== ====
    gd drive
    e) Edit existing remote
    n) New remote
    d) Delete remote
    r) Rename remote
    c) Copy remote
    s) Set configuration password
    q) Quit config
    e/n/d/r/c/s/q> q #輸入q退出

複製 index.js 所有程式碼到 workers 上#

google Drive 雲端硬碟 搭配workers 建立Index
https://aishuafei.com/posts/google-drive-雲端硬碟-搭配workers-建立index/
作者
愛耍廢
發佈於
2020-08-29
許可協議
CC BY-NC-SA 4.0