简体   繁体   English

没有 storage.buckets.list 访问 Google Cloud 项目的权限?

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

I wrote a Ruby script that will upload an audio file to a Google Cloud Storage.我写了一个 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

Though, everytime I run the command -> ruby video_dictation.rb, it returns me an error which is xxxxxxxxx does not have storage.buckets.list access to the Google Cloud project.虽然,每次我运行命令 -> ruby video_dictation.rb 时,它都会返回一个错误,即xxxxxxxxx 没有 storage.buckets.list 访问 Google Cloud 项目的权限。 (Google::Cloud::PermissionDeniedError) . (谷歌::云::PermissionDeniedError)

Any help, suggestions?任何帮助,建议? Thanks!谢谢!

Should be permission issue.应该是权限问题。

  1. Try to create a service account.尝试创建一个服务帐户。 It looks like this "my-storage-bucket@yourprojectname.iam.gserviceaccount.com"它看起来像这样“my-storage-bucket@yourprojectname.iam.gserviceaccount.com”
  2. Go to IAM & Admin -> Permission Go 到 IAM 和管理员 -> 权限
  3. Assign that service account with "Storage Object Admin" role.为该服务帐户分配“存储 Object 管理员”角色。
  4. Try your code again.再次尝试您的代码。 If is working, please scope down your permission to the below list based on your needs.如果工作正常,请根据您的需要将您的许可记录到下面的列表中。

存储对象管理员权限分析

5. Remember to download the json key file for that particular service account. 5. 请记住下载该特定服务帐户的 json 密钥文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google云端存储 - Rails网络应用 - 针对不同环境的不同存储桶和不同的访问密钥 - Google Cloud Storage - Rails web app - different buckets and different access keys for different environments 使用Rails从Google Cloud Storage获取共享存储桶 - Get shared buckets from Google Cloud Storage using Rails 在整合 Active Storage 和 Google Cloud Storage 时,storage.yml 中的“project”键真的有必要吗? - When intergrating Active Storage and Google Cloud Storage, is the "project" key in storage.yml really necessary? 如何将本地存储(活动存储)迁移到谷歌云存储 - How to migrate local storage (active storage) to google cloud storage 使用 Google Cloud Storage 和 Carrierwave 保存图像时出错 - Errors in saving image with Google Cloud Storage and Carrierwave Rails - 将私有文件上传到 Google Cloud Storage - Rails - Upload private file to Google Cloud Storage 在Rails网站上将图像上传到Google云存储 - Uploading an image to google cloud storage on a rails site 使用带有自定义域的私有谷歌云存储 - Using a private google cloud storage with a custom domain 未初始化的常量CarrierWave :: Storage :: Fog与Google Cloud Storage - uninitialized constant CarrierWave::Storage::Fog with Google Cloud Storage Google reCAPTCHA 错误:提供的云项目编号不拥有给定的 reCAPTCHA 密钥 - Google reCAPTCHA error: The provided cloud project number does not own the given recaptcha key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM