Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[storage|aws] Support overriding request parameters #345

Closed
kneath opened this issue Jun 3, 2011 · 3 comments
Closed

[storage|aws] Support overriding request parameters #345

kneath opened this issue Jun 3, 2011 · 3 comments

Comments

@kneath
Copy link

kneath commented Jun 3, 2011

I was looking to create a signed url that included a response-content-disposition request parameter override so that I could change the filename that the browser downloaded. You can see examples of this on Amazon's documentation: http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTObjectGET.html

… but I ran into no amount of issues, probably due to my misunderstanding of Fog. But I'm pretty sure that fog doesn't allow this query param. It would be nice to support request parameter overrides in get_object_url or even url.

The way I was trying (which failed, due to the fact that params[:query] was a string that didn't have keys — and using a hash mashed my key/value together without a = breaking the request):

storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => S3_ACCESS_KEY, :aws_secret_access_key => S3_SECRET)

expires = Time.now + 30*24*60*60
url = storage.url({
            :headers  => {},
            :host     => 's3.amazonaws.com',
            :method   => 'GET',
            :path     => "#{S3_BUCKET}/#{Release.latest_release.guid}.zip",
            :query    => 'response-content-disposition=attachment%3B%20filename%3Dtest.zip'
          }, expires)

The end result was that it seemed impossible to get a &response-content-disposition=attachment%3B%20filename%3Dtest.zip into the url string to be signed.

@geemus geemus closed this as completed in 8fb8642 Jun 7, 2011
@geemus
Copy link
Member

geemus commented Jun 7, 2011

That commit should fix it so that you can pass a hash as the query (with the content related stuff in there) and have it do the right thing. Will try to get a release out later this week (probably tomorrow or Thursday, but have a few more things to review/merge). Thanks!

@masterkain
Copy link
Contributor

geemus@8fb8642#L0R68 supposes that params[:query] exists, while this might not hold true. I was hacking Paperclip to expose the computed and private url of attachment and found this.

My suggested fix is to declare params[:query] ||= {} on line 66.

@geemus
Copy link
Member

geemus commented Jun 8, 2011

good catch, here is the fix: geemus@73b30b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants