Created
February 1, 2011 02:08
-
-
Save yorkxin/805284 to your computer and use it in GitHub Desktop.
sample code of supporting to S3's GET link with response-* params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://github.com/rightscale/right_aws/pull/47 for more details | |
# Traditional way, without headers and response-* params | |
s3instance.get_link('bucket_name', 'key/song.mp3', 86400) | |
#=> https://bucket_name.s3.amazonaws.com:443/key%2Fsong.mp3?Signature=vIh5...&Expires=1296611902&AWSAccessKeyId=AK... | |
# To generate url with response-* params, headers parameter must be specified, | |
# and response-* params are in hash style | |
s3instance.get_link('bucket_name', 'key/song.mp3', 86400, | |
{}, # empty additional headers | |
{ | |
"response-content-disposition" => "attachment; filename=good_song.mp3", # specify Content-disposition and filename | |
"response-cache-control"=>"No-cache" # specify Cache-control | |
} | |
) | |
#=> https://bucket_name.s3.amazonaws.com:443/key%2Fsong.mp3?response-cache-control=No-cache&response-content-disposition=attachment; filename=good_song.mp3&Signature=7TLD...&Expires=1296611902&AWSAccessKeyId=AK... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment