使用 Google Cloud 控制台探索物件儲存空間

瞭解如何透過 Google Cloud 控制台開始使用 Cloud Storage。

Cloud Storage 產生的費用取決於您耗用的資源。這項快速入門導覽課程使用的 Cloud Storage 資源通常不到 $0.01 美元。


如要直接在 Google Cloud 控制台中,按照這項工作的逐步指南操作,請按一下「Guide me」(逐步引導)

「Guide me」(逐步引導)


事前準備

  1. 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Make sure that you have the following role or roles on the project: Storage Admin

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. Click Select a role, then search for the role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Make sure that you have the following role or roles on the project: Storage Admin

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. Click Select a role, then search for the role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.

建立值區

「bucket」是 Cloud Storage 中存放資料的基本容器。

如要建立值區,請按照下列指示操作:

  1. 前往 Google Cloud 控制台的「Cloud Storage bucket」頁面。

    前往「Buckets」(值區) 頁面

  2. 點選 「建立」

  3. 在「Get started」(開始使用) 專區中,輸入 bucket 的全域專屬名稱。

  4. 在「選擇資料儲存的位置」部分,選取「位置類型」的「區域」。這個欄位請使用預設值。

  5. 在「選擇資料儲存方式」部分,使用預設值。

  6. 在「選取如何控制物件的存取權」部分,取消勾選「強制禁止公開存取這個 bucket」核取方塊。這樣一來,您稍後就能分享該物件。

  7. 在「選擇保護物件資料的方式」部分,使用預設值。

  8. 點選「建立」

大功告成,您剛剛建立了一個 Cloud Storage 值區!

將物件上傳至 bucket

  1. 將下列圖片儲存至您的裝置。

    腳掌向外伸出的小貓。

  2. 在「Bucket details」(值區詳細資料) 頁面的「Objects」(物件) 分頁中,按一下「Upload」(上傳)。 然後選取「上傳檔案」

  3. 在裝置上找到並選取先前儲存的圖片。

上傳完畢後,應該會看見檔案名稱與相關資訊,例如檔案大小和類型等。

下載物件

如要從值區下載圖片,請按一下「下載」

分享物件

按照下列指示操作,將 bucket 開放公開存取,並為圖片建立公開存取網址:

  1. 按一下「Permissions」(權限) 分頁標籤。

  2. 點選「授予存取權」。

  3. 在「New principals」(新增主體) 欄位中輸入 allUsers

  4. 在「Select a role」(選取角色) 清單中,選取「Cloud Storage」。然後選取「Storage 物件檢視者」

  5. 按一下 [儲存]

  6. 在「確定要將這項資源設為公開嗎?」對話方塊中,按一下「允許公開存取」

    如要確認是否已公開共用物件,請點選「物件」分頁標籤來返回物件清單。物件的「公開存取權」欄應會顯示「在網際網路上公開」。「複製網址」按鈕會提供可以分享的網址,類似下列內容: https://storage.googleapis.com/YOUR_BUCKET_NAME/kitten.png

如要從 bucket 移除公開存取權,並停止公開共用圖片,請按照下列步驟操作:

  1. 按一下「Permissions」(權限) 分頁標籤。

  2. 在「主體」欄中找出「allUsers」主體,然後勾選相關聯的核取方塊。

  3. 按一下「移除存取權」按鈕,然後在系統提示時確認。

    在「物件」分頁中,您應該會看到圖片已沒有「複製網址」按鈕。

建立模擬資料夾

  1. 按一下「物件」分頁中的「建立資料夾」

  2. 在「Name」(名稱) 欄位中,輸入 quickstart-folder

  3. 點選「建立」

    模擬資料夾會顯示在值區中,並帶有資料夾圖示,以便與物件區分。

  4. 如要將檔案上傳至模擬資料夾,請按照下列步驟操作:

    1. 按一下「quickstart-folder」

    2. 按一下「上傳」,然後選取「上傳檔案」

    3. 在裝置上找到並選取先前儲存的圖片。

      上傳完畢後,應該會看見檔案名稱與相關資訊,例如檔案大小和類型等。

刪除物件

  1. 在「資料夾瀏覽器」面板中,按一下 bucket 名稱。

  2. 勾選「quickstart-folder」旁的核取方塊。

  3. 按一下「刪除」,然後在系統提示時確認刪除。

    模擬資料夾和其中的所有物件都會遭到刪除。

清除所用資源

為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。

  1. 前往 Google Cloud 控制台的「Cloud Storage bucket」頁面。

    前往「Buckets」(值區) 頁面

  2. 找出您建立的值區,並選取旁邊的核取方塊。

  3. 按一下「刪除」,然後在系統提示時確認刪除。

後續步驟