pra
pra

Reputation: 363

How to set filename for presigned_url in s3

I am using amazon sdk version 2

For presigned_url i use the below url = signer.presigned_url(:get_object, bucket: bucket, key: key)

But how do i set the filename?( For users when they select save as..)

Upvotes: 2

Views: 2421

Answers (2)

pra
pra

Reputation: 363

Need to add response_content_disposition and set the filename

signer = Aws::S3::Presigner.new signer.presigned_url(:get_object, bucket: bucket, key: key, response_content_disposition: "attachment;filename=test.pdf")

Upvotes: 4

Brandon Joyce
Brandon Joyce

Reputation: 3110

If you add ${filename} to the key it will be replaced with the filename chosen when uploading the file.

Upvotes: 1

Related Questions