0
votes

I want to download some reports from Google Cloud Storage and I'm trying the 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. How can I achieve that? Do I need to have billing enabled?

2

2 Answers

2
votes

In order to list all the object in a bucket you can use 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. You can try the API before implementing it in your code.

I hope that helps.

1
votes

You do not need billing enabled to download objects from a GCS bucket. Operations on GCS buckets are billed to the project that owns the bucket. You only need to enable billing in order to create a new bucket.

Downloading a single file using the Gcloud gem looks like this:

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