module Shrine::Plugins::UploadOptions

  1. lib/shrine/plugins/upload_options.rb

The upload_options plugin allows you to automatically pass additional upload options to storage on every upload:

plugin :upload_options, cache: { acl: "private" }

Keys are names of the registered storages, and values are either hashes or blocks.

plugin :upload_options, store: ->(io, context) do
  if [:original, :thumb].include?(context[:version])
    { acl: "public-read" }
  else
    { acl: "private" }
  end
end

If you're uploading the file directly, you can also pass :upload_options to the uploader.

uploader.upload(file, upload_options: { acl: "public-read" })

Methods

Public Class

  1. configure

Public Class methods

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