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

Cloud Storage 可讓您大規模儲存及擷取非結構化資料。在本快速入門導覽課程中,您將使用 Google Cloud 控制台建立 bucket、上傳物件,以及共用該物件。

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. 點選 「Create」(建立)。

  3. 在「Get started」(開始使用) 部分,輸入 bucket 的全域不重複名稱。

  4. 在「Choose where to store your data」(選擇資料的儲存位置) 專區中,針對「Location type」(位置類型) 選取「Region」(區域)。請在這個欄位使用預設值。

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

  6. 在「Choose how to control access to objects」(選取如何控制物件的存取權) 部分,取消勾選「Enforce public access prevention on this bucket」(強制禁止公開存取這個 bucket) 核取方塊。這樣稍後您就可以共用這個物件。

  7. 在「Choose how to protect object data」(選擇保護物件資料的方式) 部分,使用預設值。

  8. 點選「建立」。

至此您已成功建立 Cloud Storage bucket!

將物件上傳至 bucket

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

    腳掌向外伸出的小貓。

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

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

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

下載物件

如要從 bucket 下載圖片,請按一下 「Download」(下載)。

共用物件

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

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

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

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

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

  5. 按一下 [儲存]。

  6. 在「Are you sure you want to make this resource public?」(確定要將這項資源設為公開嗎?) 對話方塊中,按一下「Allow public access」(允許公開存取)。

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

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

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

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

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

    在「Objects」(物件) 分頁中,您應該會看到圖片不再有「Copy URL」(複製網址) 按鈕。

建立模擬資料夾

  1. 點選「物件」分頁中的「建立資料夾」。

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

  3. 點選「建立」。

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

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

    1. 按一下「quickstart-folder」。

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

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

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

刪除物件

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

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

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

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

清除所用資源

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

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

    前往「Buckets」(值區) 頁面

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

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

後續步驟