:create_on_promoteoption has been added to the
derivativesplugin for automatically creating derivatives after the attached cached file is promoted to permanent storage.
Shrine.plugin :derivatives, create_on_promote: true
:auto_extractionoption has been added to the
store_dimensionsplugin for skipping automatically extracting dimensions on upload.
Shrine.plugin :store_dimensions, auto_extraction: false
:skip_niloption has been added to the
add_metadataplugin for excluding metadata keys whose values are nil.
class PdfUploader < Shrine add_metadata :pages, skip_nil: true do |io| if is_pdf?(io) reader = PDF::Reader.new(io) reader.page_count else # If this is not a PDF, then the pages metadata will not be stored nil end end end
:downloadoption has been added to derivatives processors in
derivativesplugin for skipping converting the source IO object into a file. This can be used to avoid a potentially expensive download/copy when the derivatives processor doesn't need the file.
Attacher.derivatives :my_processor, download: false do |source| source #=> Could be File, Shrine::UploadedFile, or other IO-like object shrine_class.with_file(source) do |file| # can force download/copy if necessary with `with_file`, end end
upload_endpointnow handles calling
Shrine.upload_responsemethod from a Rails controller.
derivation_endpointplugin now applies the
versionquery parameter to the derivation when creating the response.
Aws:S3::EncryptionV2::Clientis now supported by the S3 storage for client-side encryption.
derivation_endpointnow reduces the possibility of timing attacks by comparing URL signatures in constant time using
derivativesplugin now copies non-file source IO objects to disk before passing them to the processor. This is consistent with how a
Shrine::UploadedFileobject is downloaded to disk.
activerecordplugins now call
Attacher#reloadwhen reloading the model, which reloads the attached files but keeps other attacher state.
derivativesplugin doesn't download the attached file anymore if attempting to process derivatives when no derivatives processor was defined.
mirroringplugin now forwards attacher options when uploading to mirror storages.
presign_endpointplugin now handles the
OPTIONSHTTP verb, which newer versions of Uppy are requesting.
Shrine::Storage::Memory#opennow always returns a
StringIOin the file content's original encoding, instead of the encoding set by
Encoding.default_internal. This works around a bug in
StringIOintroduced in Ruby 2.7.0.
remove_attachmentplugin now deletes the removed file if a new file was attached right after removal.
If you were passing a non-file IO object to the derivatives processor, Shrine will now convert it into a file beforehand. If you're currently doing this and are converting the IO object into a file inside the processor, you can now remove the conversion code to avoid doubling the amount of disk writes.
When reloading a Sequel/ActiveRecord model, any attacher state other than uploaded files will now be retained after the reload. If you were relying on all the attacher state being re-initialized, you'll need to update your code.