Skip to content

Instantly share code, notes, and snippets.

@yorkxin
Created February 1, 2011 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorkxin/805284 to your computer and use it in GitHub Desktop.
Save yorkxin/805284 to your computer and use it in GitHub Desktop.
sample code of supporting to S3's GET link with response-* params
# 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