【问题标题】:Does not have storage.buckets.list access to the Google Cloud project?没有 storage.buckets.list 访问 Google Cloud 项目的权限?
【发布时间】:2021-06-04 05:03:52
【问题描述】:

我编写了一个 Ruby 脚本,它将音频文件上传到 Google 云存储。

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 项目的权限。 (Google::Cloud::PermissionDeniedError).

任何帮助,建议?谢谢!

【问题讨论】:

  • 当前凭证的作用是什么?您有当前凭证的电子邮件吗?您能否提供有关基础身份的更多详细信息?

标签: ruby-on-rails ruby google-cloud-platform google-speech-to-text-api


【解决方案1】:

应该是权限问题。

  1. 尝试创建一个服务帐户。它看起来像这样“my-storage-bucket@yourprojectname.iam.gserviceaccount.com”
  2. 转到 IAM 和管理 -> 权限
  3. 为该服务帐户分配“存储对象管理员”角色。
  4. 再次尝试您的代码。如果有效,请根据您的需要将您的权限范围缩小到以下列表。

5。请记住下载该特定服务帐户的 json 密钥文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-21
    • 2019-12-22
    • 2020-12-03
    • 2018-12-26
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多