module Shrine::Plugins::DefaultUrlOptions

  1. lib/shrine/plugins/default_url_options.rb

The default_url_options plugin allows you to specify URL options that will be applied by default for uploaded files of specified storages.

plugin :default_url_options, store: { download: true }

You can also generate the default URL options dynamically by using a block, which will receive the UploadedFile object along with any options that were passed to UploadedFile#url.

plugin :default_url_options, store: -> (io, **options) do
  { response_content_disposition: ContentDisposition.attachment(io.original_filename) }

In both cases the default options are merged with options passed to UploadedFile#url, and the latter will always have precedence over default options.


Public Class

  1. configure

Public Class methods

configure (uploader, options = {})
[show source]
# File lib/shrine/plugins/default_url_options.rb, line 22
def self.configure(uploader, options = {})
  uploader.opts[:default_url_options] ||= {}