I've added support into aws-s3 for response-* params and the likes (I needed to change the name of some downloaded
files).
I've kept changes to a minimum. They are essentially:
1. make public AWS::S3::Authentication::Signature#canonical_string
2. make public AWS::S3::Authentication::CanonicalString#extract_significant_parameter, and add support here for all
params provided into request.path
3. call canonical_string.extract_significant_parameter also from QueryString#build and adjust the result accordingly
4. suppress params from path in AWS::S3::Connection#url_for after building the query string
The really important bit is that extract_significant_parameter needs to unescape params when building CanonicalString
but not when building QueryString.
Notes:
* I've deleted the misleading comment above QueryString#build, in fact sorting is only needed
in extract_significant_parameter so that Amazon can correctly compute the expected signature.
* AWS::S3::Connection#url_for only allows authenticated response-* params... maybe this limitation should be removed
in the future.
Based on:
* https://github.com/amazonwebservices/aws-sdk-for-ruby/blob/master/lib/aws/s3/request.rb
* http://blog.yorkxin.org/2011/02/01/rightaws-get-link-response
Example:
---
filename = "my nice filename.txt"
content_disposition = AWS::S3::Authentication::CanonicalString::cgi_escape("attachment;
filename=\"#{filename}\"")
object = "#{path}?response-content-disposition=#{content_disposition}"
AWS::S3::S3Object.url_for(object, bucket, :expires_in => 2.hours)
---
Thanks,
--Andrea
|