簡體   English   中英

沒有 storage.buckets.list 訪問 Google Cloud 項目的權限?

[英]Does not have storage.buckets.list access to the Google Cloud project?

我寫了一個 Ruby 腳本,它將音頻文件上傳到谷歌雲存儲。

def upload_to_Google_cloud(audio_file)

    project_id = "<project_id>"
    key_file = "<json_file>"

    storage = Google::Cloud::Storage.new project: project_id, keyfile: key_file

    bucket_name = storage.buckets.first.name 
    puts bucket_name
      
    bucket = storage.bucket bucket_name

    local_file_path = "/path/#{audio_file}"

    file = bucket.create_file local_file_path, "#{audio_file}.flac"
    return "Uploaded #{file.name}"
end

雖然,每次我運行命令 -> ruby video_dictation.rb 時,它都會返回一個錯誤,即xxxxxxxxx 沒有 storage.buckets.list 訪問 Google Cloud 項目的權限。 (谷歌::雲::PermissionDeniedError)

任何幫助,建議? 謝謝!

應該是權限問題。

  1. 嘗試創建一個服務帳戶。 它看起來像這樣“my-storage-bucket@yourprojectname.iam.gserviceaccount.com”
  2. Go 到 IAM 和管理員 -> 權限
  3. 為該服務帳戶分配“存儲 Object 管理員”角色。
  4. 再次嘗試您的代碼。 如果工作正常,請根據您的需要將您的許可記錄到下面的列表中。

存儲對象管理員權限分析

5. 請記住下載該特定服務帳戶的 json 密鑰文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM