gcloud storage
(正式發布) 是與 Cloud Storage 互動時建議使用的指令列工具。本頁面說明兩種工具的主要差異和指令對應,協助您從 gsutil
轉換到 gcloud storage
。如需 gcloud storage
工具的詳細說明,請參閱 gcloud storage
參考說明文件。
如要瞭解如何安裝及開始使用 Google Cloud CLI,請參閱「安裝 Google Cloud CLI」。
行為差異
以下各節說明 gsutil
和 gcloud storage
的行為差異。
平行叫用
gcloud storage
不支援從不同終端機同時執行多個 CLI 執行個體。
平行處理
gcloud storage
支援平行處理。
萬用字元處理
gcloud storage
會簡化多個星號。如果連續使用三個以上的星號 (***
),系統會將其視為單一星號 (*
)。
處理階層命名空間 bucket
gcloud storage
可用於建立及管理已啟用階層命名空間的 bucket。
輸出格式
gcloud storage
和 gsutil
指令的輸出格式不同。
雖然記錄格式等微小變更可能不會影響您,但錯誤訊息和資料清單的重大差異可能會導致自動化指令碼中斷。
如果您有依賴剖析 gsutil
指令輸出的指令碼,請先檢查並更新這些指令碼,使其符合 gcloud storage
格式,再進行轉換。
對應的 gcloud 指令
所有現有的 gsutil
指令在 gcloud storage
中都有對等的指令,但還是有一些例外。如要取得 gcloud storage
指令的完整清單,請參閱參考說明文件或執行 gcloud storage --help
。下表簡要說明常見 gsutil
指令的變更。
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
管理存取控制清單 (ACL) |
gsutil acl get gsutil acl set gsutil acl ch |
gcloud storage RESOURCE describe --format="multi(acl:format=json)" gcloud storage RESOURCE update --acl-file=ACL_FILE_PATH gcloud storage RESOURCE update --add-acl-grant=GRANT gcloud storage RESOURCE update --remove-acl-grant=GRANT |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
串連物件並顯示物件內容 |
gsutil cat |
gcloud storage cat |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
將物件合併為新物件,藉此串連物件 |
gsutil compose |
gcloud storage objects compose |
附註如要在gcloud storage objects compose 中套用先決條件,請使用特定旗標,例如 --if-generation-match 或 --if-metageneration-match 。 |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
複製物件和其他資源 |
gsutil cp |
gcloud storage cp |
附註使用 Google Cloud 控制台建立的模擬資料夾會被視為 0 位元組的預留位置物件。 處理錯誤時, 下載物件時, |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
顯示物件使用的磁碟空間總量 |
gsutil du |
gcloud storage du |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
計算檔案雜湊值 |
gsutil hash |
gcloud storage hash |
附註
|
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
管理 bucket 標籤 |
gsutil label get gsutil label set gsutil label ch |
gcloud storage buckets describe gcloud storage buckets update gcloud storage buckets update |
附註在單一 |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
列出 bucket、物件和資料夾 |
gsutil ls |
gcloud storage ls |
附註使用萬用字元列出專案中的物件時, 使用
|
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
移動及重新命名物件或目錄 |
gsutil mv |
gcloud storage mv |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
就地重寫物件 |
gsutil rewrite |
gcloud storage objects update |
附註如果 boto 設定檔中已設定
|
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
移除物件或值區 |
gsutil rm |
gcloud storage rm |
附註系統不支援 已知問題:同時使用 |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
同步處理兩個 bucket 或目錄的內容 |
gsutil rsync |
gcloud storage rsync |
附註根據預設,如果來源和目的地的物件大小和上次修改時間相符,
|
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
設定上傳物件的中繼資料 |
gsutil setmeta |
gcloud storage objects update |
附註
在 |
作業 | gsutil 指令 | gcloud storage 指令 |
---|---|---|
顯示物件狀態 |
gsutil stat |
gcloud storage objects list --stat --fetch-encrypted-object-hashes |
附註
|