Add option to support 'Requester Pays' buckets #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #57
GCS has an option on buckets to make them a "Requester Pays" type of bucket: https://cloud.google.com/storage/docs/requester-pays. In short, this allows tracing of who/what is actually requesting an upload/download.
To query a bucket where "requester pays" is enabled, the
userProject
needs to be added in the URL. The GCS Ruby library provides this as an optionaluser_project
keyword argument toProject#bucket
: https://github.com/googleapis/google-cloud-ruby/blob/7523214b3c64f88db5e96269b397b066abf4b92e/google-cloud-storage/lib/google/cloud/storage/project.rb#L208-L216When this is not passed, an error is thrown when listing/uploading files in a requester-pays bucket:
Bucket is a requester pays bucket but no user project provided. (Google::Cloud::InvalidArgumentError)
This MR adds support for "requester pays"-buckets by accepting a
user_project
parameter (defaults tonil
) on the Storage initializer, which is then used when callingProject#bucket
.