photo.file_url(response_content_disposition: ContentDisposition.attachment(photo.file.original_filename))
--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/6c680e40-c947-4531-ada0-30a9be796012%40googlegroups.com.
You can use the default_url_options plugin in the uploader you want to have this content disposition header:class MyUploader < Shrineplugin :default_url_options, store: -> (io, options) {{ response_content_disposition: ContentDisposition.attachment(io.original_filename) }}end
Kind regards,
Janko
On 8 Aug 2019, 18:35 +0200, kevin.s...@webascender.com, wrote:
Is it possible to set a default "content_disposition" header inside an uploader that will retain the original filename but use "attachment" instead of "inline"?--I'm using the S3 storage which defaults to "inline" for all uploads, but for a specific uploader class I want to use the "attachment" disposition header on everything uploaded to S3 via this uploader.Right now my workaround is to do things like this inside every view where I want to link to an uploaded file:
photo.file_url(response_content_disposition: ContentDisposition.attachment(photo.file.original_filename))
But it's getting cumbersome when I do this in a lot of places for the same file / uploader type across lots of views...Thanks for any help!
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/45e90401-d9fb-47e3-b4ee-7f9165ee5281%40googlegroups.com.
That's a good point, I was also thinking that this should be possible. I added it to my TODO list for Shrine 3.0, which will be the next version, though it will take a while to get released.In the meantime, you can override `Shrine::UploadedFile#url` in your uploader:class MyUploader < Shrineclass UploadedFiledef url(io, **options)content_disposition = ContentDisposition.attachment(original_filename)super(io, response_content_disposition: content_disposition, **options)endendend
Kind regards,
Janko
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/45e90401-d9fb-47e3-b4ee-7f9165ee5281%40googlegroups.com.