Last Updated: January 28, 2019
· causztic

Setting Response Headers for aws_s3 download requests in ruby

I am using presigned urls for users to download their files from S3 and they were always opened by default by their browser and I want to override the behavior.
According to the documents, the only parameters they accept are :expires, :virtual_host, and :secure.

However, after mucking around I realised you could set the header in the method which wasn't mentioned in the docs, like so:

client =, secret))
signer = client)
signer.presigned_url(:get_object, bucket: bucket, key: key, response_content_disposition: 'attachment')

No need for hacks to create a custom method for it!