Non-tech founder’s guide to choosing the right software development partner Download Ebook
Home>Blog>Force downloading of file in shrine 3

Force Downloading of File in Shrine 3

Usually we get link to file like this:


irb(main):001:0> Document.last.asset.url

=> "https://bucket-development.s3.amazonaws.com/store/document/1/asset/2ac6a0262aee19787dcf87075043afef.pdf"

But in this case, this file will be opened in browser.

If you want to force download file you should add response_content_disposition and make private link (if it’s not true):


irb(main):002:0> Document.last.asset.url(public: false, response_content_disposition: "attachment")

=> "https://bucket-development.s3.amazonaws.com/store/document/1/asset/2ac6a0262aee19787dcf87075043afef.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXXXXXXXXXXXXX%2F20201211%2Fus-west-3%2Fs3%2Faws4_request&X-Amz-Date=20201211T122731Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Discover More Reads

Real Stories & Real Success

Do you have a tech idea?

Let’s talk!

By submitting this form, you agree with JetRockets’ Privacy Policy

If you prefer email, write to us at hello@jetrockets.com