[英]Get shared buckets from Google Cloud Storage using Rails
I want to download some reports from Google Cloud Storage and I'm trying the Gcloud gem . 我想从Google Cloud Storage下载一些报告,并且正在尝试Gcloud gem 。 I managed to successfully connect and now I am able to list my buckets, create one, etc.
我设法成功连接,现在可以列出我的存储桶,创建存储桶等。
But I can't find a way to programically get files from buckets, which are shared with me. 但是我找不到一种以编程方式从存储桶中获取文件的方法,这些存储桶是与我共享的。 I got and address like
gs://pubsite...
and I need to connect to that bucket, to download some files. 我得到的地址类似于
gs://pubsite...
,我需要连接到该存储桶以下载一些文件。 How can I achieve that? 我该如何实现? Do I need to have billing enabled?
我需要启用计费功能吗?
In order to list all the object in a bucket you can use Google Cloud Storage Object list API . 为了列出存储桶中的所有对象,您可以使用Google Cloud Storage Object list API 。
You need to provide the Bucket ID and should have the access to the bucket to read the objects. 您需要提供存储桶ID,并且应该有权访问存储桶以读取对象。 You can try the API before implementing it in your code.
您可以先尝试使用API,然后再在代码中实现它。
I hope that helps. 希望对您有所帮助。
You do not need billing enabled to download objects from a GCS bucket. 您无需启用结算即可从GCS存储桶下载对象。 Operations on GCS buckets are billed to the project that owns the bucket.
GCS存储桶上的操作会向拥有该存储桶的项目收费。 You only need to enable billing in order to create a new bucket.
您只需启用计费即可创建新的存储桶。
Downloading a single file using the Gcloud gem looks like this: 使用Gcloud gem下载单个文件如下所示:
require "gcloud"
gcloud = Gcloud.new
storage = gcloud.storage
bucket = storage.bucket "pubsite"
file = bucket.file "somefile.png"
file.download "/tmp/somefile.png"
There are some examples at http://googlecloudplatform.github.io/gcloud-ruby/docs/v0.2.0/Gcloud/Storage.html http://googlecloudplatform.github.io/gcloud-ruby/docs/v0.2.0/Gcloud/Storage.html中有一些示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.