畑乃おいも / Hatano Oimo
1139 字
6 分鐘
google Drive 雲端硬碟 搭配workers 建立Index

介紹
可將你的 google drive 內檔案在 workers 上建立 index,可以看一下作者的 Demo:oss.achirou.workers.dev/(在新分頁開啟),可以線上觀看影片,看圖片,也可以下載任何檔案,index 網頁是可以設定密碼也不用怕被陌生人看到,試試看如何使用,不懂程式語言也可以手把手輕鬆做出來。
- 使用 GoIndex-theme-acrou 版本 github:goindex-theme-acrou(在新分頁開啟)
設定方法
請先註冊 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 onen) New remotes) Set configuration passwordq) Quit confign/s/q> n # 輸入n 建立remotename> gdType of storage to configure.Enter a string value. Press Enter for the default ("").Choose a number from below, or type in your own value1 / 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 IdLeave blank normally.Enter a string value. Press Enter for the default ("").client_id> # 留空OAuth Client SecretLeave 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 value1 / 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 but5 | does not allow any access to read or download file content.\ "drive.metadata.readonly"scope> 1 # 輸入 1ID of the root folderLeave blank normally.Fill in to access "Computers" folders (see docs), or for rclone to usea non root folder as its starting point.Enter a string value. Press Enter for the default ("").root_folder_id>Service Account Credentials JSON file pathLeave 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) Yesn) No (default)y/n> n # 輸入 nRemote configUse auto config?* Say Y if not sure* Say N if you are working on a remote or headless machiney) Yes (default)n) Noy/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=2tcyRHXyFQr1zZkmGcwYMwLog in and authorize rclone for accessEnter verification code> 4/5wFubkoEF4ivZfYC3B8mbxPL8tRbKv4ZO8dKPqizl1nzbm2dQgfrtKgConfigure this as a team drive?y) Yesn) No (default)y/n> y # 輸入 YFetching team drive list...Choose a number from below, or type in your own value1 / share\ "0ANz2seq1rrO59PVA"Enter a Team Drive ID> 1 # 輸入 1 或選擇你要的team drive--------------------[gd] # 以下是設定檔資訊,請複製 refresh_tokentype = drivescope = drivetoken = {"access_token":"","token_type":"Bearer","refresh_token":"...","expiry":"2020"}team_drive = 0ANz2seq1rrO59PVAroot_folder_id =--------------------y) Yes this is OK (default)e) Edit this remoted) Delete this remotey/e/d> y # 輸入yCurrent remotes:Name Type==== ====gd drivee) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q #輸入q退出
複製 index.js 所有程式碼到 workers 上
-
建立 worker

-
複製 index.js code
-
設定配置
-
client_id、client_secret 可不改,使用默認的,建議使用自己的 api
-
refresh_token 命令列輸入 rclone config show 可查詢 config 檔
-
新增 team drive(團隊盤 ID) 假設團隊盤網址是:https://drive.google.com/drive/u/0/folders/0AAVuckskaiewDUk9PVA(在新分頁開啟)
0AAVuckskaiewDUk9PVA是 ID -
例子: 如果不開放請必須設定帳號密碼、name 可隨意取名稱
roots: [{id: "0AAVuckskaiewDUk9PVA",name: "TeamDrive",pass: "", // 沒設定等於不需密碼},{id: "root", // root 是個人雲端name: "PrivateDrive",user: "abc", //帳號pass: "123", //密碼protect_file_link: true,},{id: "",name: "folder1",pass: "",},],
儲存部署就完成了,最上方可開啟網址

-
google Drive 雲端硬碟 搭配workers 建立Index
https://aishuafei.com/posts/google-drive-雲端硬碟-搭配workers-建立index/
