In the Amazon S3 SDK, when generating a presigned URL, I can generate a URL setting the content-disposition, but I cannot find a similar way of configuring these options using Google.
The method call available to us is:
https://www.rubydoc.info/gems/google-cloud-storage/0.20.0/Google/Cloud/Storage/File#signed_url-instance_method
I am trying to upload a file directly to a Google bucket and not via my Rails server, and want to set the content-disposition of the file being uploaded via the presigned URL. Is there a way of doing this? Is there a way of setting object meta data via a presigned URL?
require "google/cloud"
gcloud = Google::Cloud.new
storage = gcloud.storage
bucket = storage.bucket "my-todo-app"
file = bucket.file "avatars/heidi/400x400.png"
shared_url = file.signed_url
# The parameters it takes is: signed_url(method: nil, expires: nil, content_type: nil, content_md5: nil, issuer: nil, client_email: nil, signing_key: nil, private_key: nil)
# how do we add content_disposition?
# how do we add object meta data?
I'm looking for the same answer, and so far I have found this other Stack Overflow article, which doesn't directly address Ruby SDK, but it does offer a good piece of information.
Google Cloud Storage: download a file with a different name
You can also generate signed URLs that include the response-content-disposition query parameter. Then the users will be making authorized requests to download the resource.
So it appears that you can add the query parameter ?response-content-disposition=[disposition-string-urlencoded]
to the resulting signed string.
So, I looked at the File object definition in the Ruby SDK and it appears you can do this:
file.content_dispostion = "attachment" # or whatever your disposition is
url = file.signed_url
NOTE: If you read my entry before I edited it, my apologies.