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: "attachment; filename=\"#{io.original_filename}\""}
end

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

Methods

Public Class

  1. configure

Public Class methods

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