☁️

rclone + Google Drive

讓龍蝦自動上傳檔案到雲端

自動上傳 分享連結 遠端取檔 備份同步

人在外面也能叫龍蝦傳檔案給你!

🤔 為什麼需要這個功能?

1人在外面 - 不在電腦旁邊,但需要主機上的檔案

2LINE 限制 - LINE 無法直接傳送某些格式的檔案

3自動備份 - 讓龍蝦定期把重要檔案備份到雲端

💡 解決方案:
用 rclone 把檔案上傳到 Google Drive,然後給你分享連結!

📥 第一步:安裝 rclone

在 PowerShell(系統管理員)執行:

# 方法一:用 winget 安裝(推薦)
winget install Rclone.Rclone

# 方法二:用 Chocolatey 安裝
choco install rclone

# 方法三:用 Scoop 安裝
scoop install rclone

安裝完成後,確認版本:

rclone version
✅ 預期輸出:
rclone v1.73.0(或更新版本)

⚙️ 第二步:開始設定 rclone

在 PowerShell 輸入:

rclone config

你會看到這個畫面:

No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q>

1輸入 n(New remote)然後按 Enter

2輸入名稱:gdrive 然後按 Enter

⚙️ 第三步:選擇 Google Drive

在 Storage 選單中,找到 Google Drive

Option Storage.
Type of storage to configure.
...
23 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
24 / Google Drive        <-- 找這個!
   \ (drive)
25 / Google Photos
   \ (google photos)
...
Storage>

3輸入 24(或 drive)然後按 Enter

⚠️ 注意:數字可能因版本不同而變化,請找「Google Drive」那一項!

⚙️ 第四步:Client ID 設定

接下來會問你幾個問題,大部分直接按 Enter 用預設值:

Option client_id.
Google Application Client Id
Enter a value. Press Enter to leave empty.
client_id>

4client_id → 直接按 Enter(留空)

5client_secret → 直接按 Enter(留空)

6scope → 輸入 1(Full access)

7root_folder_id → 直接按 Enter(留空)

8service_account_file → 直接按 Enter(留空)

⚙️ 第五步:進階設定與授權

Edit advanced config?
y) Yes
n) No (default)
y/n>

9Edit advanced config? → 輸入 n

Use auto config?
y) Yes (default)
n) No
y/n>

10Use auto config? → 看情況選擇:
    • 在電腦前有瀏覽器:輸入 y(會自動開瀏覽器登入)
    • 遠端/無瀏覽器:輸入 n(會給你一個網址,用手機登入)

🔐 第六步:Google 授權

如果選 y(自動設定):

瀏覽器會自動打開 Google 登入頁面,登入後按「允許」。

如果選 n(手動設定):

你會看到一個網址:

If your browser doesn't open automatically go to the following link:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=...

Enter verification code>

11用手機或電腦打開那個網址

12登入 Google 帳號,按「允許」

13複製授權碼,貼回 PowerShell 按 Enter

✅ 第七步:完成設定

Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n>

14Shared Drive? → 輸入 n(除非你要用共用雲端硬碟)

最後確認設定:

Configuration complete.
Options:
- type: drive
- scope: drive
- token: {"access_token":"..."}

Keep this "gdrive" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>

15輸入 y 確認,然後輸入 q 退出

🧪 測試:上傳檔案到 Google Drive

測試上傳一個檔案:

# 上傳單一檔案到根目錄
rclone copy "C:\Users\user\test.txt" gdrive:

# 上傳到指定資料夾
rclone copy "C:\Users\user\test.txt" gdrive:OpenClaw-Uploads

# 上傳整個資料夾
rclone copy "C:\Users\user\Documents\MyFolder" gdrive:MyFolder

查看雲端檔案:

# 列出雲端根目錄
rclone ls gdrive:

# 列出指定資料夾
rclone ls gdrive:OpenClaw-Uploads
✅ 成功!如果沒有錯誤訊息,檔案就已經上傳到你的 Google Drive 了!

📜 建立上傳腳本

建立 gdrive-upload.ps1 腳本:

# gdrive-upload.ps1
# 上傳檔案到 Google Drive 並產生分享連結

param(
    [Parameter(Mandatory=$true)]
    [string]$FilePath,
    [string]$RemoteFolder = "OpenClaw-Uploads"
)

$fileName = Split-Path $FilePath -Leaf

# 上傳檔案
Write-Host "正在上傳 $fileName ..." -ForegroundColor Cyan
rclone copy $FilePath "gdrive:$RemoteFolder"

if ($LASTEXITCODE -eq 0) {
    Write-Host "上傳成功!" -ForegroundColor Green

    # 產生分享連結
    $link = rclone link "gdrive:$RemoteFolder/$fileName"
    Write-Host "分享連結:$link" -ForegroundColor Yellow

    # 複製到剪貼簿
    $link | Set-Clipboard
    Write-Host "(已複製到剪貼簿)" -ForegroundColor Gray
} else {
    Write-Host "上傳失敗!" -ForegroundColor Red
}

🚀 如何使用

方法一:跟龍蝦說

把 disk-audit.zip 上傳到我的 Google Drive

龍蝦會執行上傳,然後回覆你分享連結。

方法二:手動執行腳本

# 上傳檔案
& "$env:USERPROFILE\.openclaw\workspace\gdrive-upload.ps1" -FilePath "C:\path\to\file.zip"

# 上傳到指定資料夾
& "$env:USERPROFILE\.openclaw\workspace\gdrive-upload.ps1" -FilePath "C:\file.zip" -RemoteFolder "Backups"

方法三:直接用 rclone 指令

# 上傳
rclone copy "C:\file.zip" gdrive:OpenClaw-Uploads

# 產生連結
rclone link "gdrive:OpenClaw-Uploads/file.zip"

📋 rclone 常用指令

你想做的事指令
上傳檔案 rclone copy 本地路徑 gdrive:遠端路徑
下載檔案 rclone copy gdrive:遠端路徑 本地路徑
同步資料夾 rclone sync 本地 gdrive:遠端
列出檔案 rclone ls gdrive:資料夾
產生分享連結 rclone link gdrive:檔案路徑
刪除檔案 rclone delete gdrive:檔案路徑
查看設定 rclone config
🎉

Google Drive 自動上傳完成!

現在龍蝦可以幫你上傳檔案到 Google Drive 了!

📋 快速複習:
1. 安裝 rclone
2. 執行 rclone config 設定 Google Drive
3. Google 授權登入
4. 跟龍蝦說「上傳 xxx 到 Google Drive」
💡 應用場景:
• 人在外面,叫龍蝦傳檔案給你
• 定期備份重要資料到雲端
• 分享大檔案給朋友
🏠 回到首頁