Shrine 2.9.0
New Plugins
- The infer_extensionplugin has been added, which automatically infers the upload location extension from the MIME type if it's unknown. This is useful when using thedata_uriplugin (where the extension is always unknown), or theremote_urlplugin (where the extension might not be known).
Shrine.plugin :infer_extensionNew Features
- The determine_mime_typeplugin has gained built-in support for the Marcel gem, Basecamp's wrapper around the existing MimeMagic.
Shrine.plugin :determine_mime_type, analyzer: :marcel- The versionsplugin now supports saving arrays of files, as well as nested structures of arrays and hashes.
class PdfUploader < Shrine
  plugin :versions
  plugin :processing
  process(:store) do |io, context|
    [ file1, file2, ... ]
    # or
    { name1: [ file1, file2, ... ], ... }
    # or
    [ { name1: file1 }, ... ]
  end
end- UploadedFile#opencan now be called without passing a block. This is useful if you want to make it explicit when the uploaded file is opened, instead of it happening automatically when- #readis called.
uploaded_file.open  # opens the local or remote file
uploaded_file.read  # read content
uploaded_file.close # close the file- The Model#<attachment>_attachernow accepts options which are forwarded toShrine::Attacher.new.
photo.image_attacher(store: :other_store)
photo.update(image: file) # uploads to :other_storeOther improvements
- Fixed - backgroundingplugin not detecting options passed to- Shrine::Attachment.new.
- Fixed S3 storage replacing whitespace with - +symbols in original filename when assigning object's- :content_dispositionon upload.
- If an error occurs when downloading the file in - UploadedFile#downloadand- Storage::S3#download, the tempfile with partially downloaded content will now automatically be deleted.
- Shrine now uses the - frozen-string-literalfeature, which will reduce the number of string allocations.
Backwards compatibility
- The - :filenameoption of the- data_uriplugin has been deprecated in favour of the new- infer_extensionplugin.
- The - multi_deleteplugin has been deprecated, and the- versionsplugin isn't loading it by default anymore.