—
title: Shrine
2.2.0¶ ↑
New plugins¶ ↑
-
The processing plugin has been added for declaratively defining processing for a specific action, and is now the idiomatic way to define processing in Shrine:
class MyUploader < Shrine plugin :processing process(:store) do |io, context| # ... end end
-
The add_metadata plugin has been added for simpler extraction and addition of new metadata:
class ImageUploader < Shrine plugin :add_metadata add_metadata :exif do |io, context| MiniMagick::Image.new(io.path).exif end end
uploaded_file.metadata["exif"] # or uploaded_file.exif
Other features¶ ↑
-
The
UploadedFile#open
method has been added to mimicFile.open
, which opens the underlying IO only for the duration of the block:
uploaded_file.open do |io| # ... end # closes the IO
-
Add
:multipart_threshold
toStorage::S3
for specifying the filesize in bytes for when the storage should use aws-sdk’s parallelized multipart upload/copy. Defaults to 15MB.
Other improvements¶ ↑
-
Aws-sdk's parallelized multipart S3 upload/copy is now automatically used for files larger than 15MB. Previously multipart upload was never used, while multipart copy would only be used for files larger than 5GB.
-
In
Storage::S3#download
aws-sdk's downloading is now used, which retries on failed downloads. -
A
:content_length
option is now passed to multipart S3 copy request, which avoids an additional HEAD request. -
The backgrounding plugin doesn’t require anymore that the model has the attachment module included. Previously it relied on the
<attachment>_attacher
method. -
The restore_cached_data plugin previously still downloaded the whole file, once the opened IO was closed. This has been fixed in the Down gem.
-
The determine_mime_type plugin now raises an error if the
file
command is not installed or failed. -
If delete_raw plugin was loaded after moving plugin, it could cause
Errno::ENOENT
errors. This is now fixed. -
The direct_upload endpoint now always includes both
POST /:storage/upload
andGET /:storage/presign
routes, and:presign
option is now obsolete. -
Add
:callbacks
and:validations
options to sequel and activerecord plugins for disabling callbacks and validations.
Storage changes¶ ↑
-
The
UploadedFile#download
will now use#open
in caseStorage#download
isn’t implemented, which means that storage implementers don’t need to implement this method anymore. -
The
Storage#read
method isn’t used in the data_uri plugin anymore, which means storage implementers don’t need to implement this method anymore. -
The
Storage#clear!
method has been made optional in the storage linter, since it was just a convention and isn’t actually used byShrine
.