—
title: Shrine 2.12.0¶ ↑
New features¶ ↑
- 
The Shrine::Attacher#assign_remote_urlmethod has been added, which acts the same as#remote_url=but allows you to also dynamically provide options to the underlying downloader (Down.downloadby default).
attacher.assign_remote_url("https://example.com/image.jpg", downloader: { 'Cookie' => 'abc123' })
- 
The Shrine::UploadedFile#download_urlmethod has been added to thedownload_endpointplugin for explicitly generating the file URL through the download endpoint.
- 
The :redirectoption has been added todownload_endpointplugin, which makes download URLs redirect directly to the uploaded file on its storage. This allows you to avoding streaming the file through your app, and thus not having it impact your request throughput.
- 
The Shrine::Plugins::ValidationHelpers::PRETTY_FILESIZEcallbable has been added, which takes the filesize in bytes and returns the representation in correct unit. This can be used when providing custom validation error messages.
pretty_filesize = Shrine::Plugins::ValidationHelpers::PRETTY_FILESIZE pretty_filesize.call(1*1024) #=> "1.0 KB" pretty_filesize.call(1.5*1024*1024) #=> "1.5 MB" pretty_filesize.call(2*1024*1024*1024) #=> "2.0 GB"
Other improvements¶ ↑
- 
The Shrine::Storage::FileSystem#opennow forwards any additional options toFile.open.
- 
The Shrine::Storage::S3#openmethod now accepts the:rewindableoption to disable caching read content to disk.
- 
In validation error messages in filesize validators in the validation_helpersplugin show specified limits in the appropriate unit, instead of always using megabytes.
- 
Shrine::UploadedFile#openwill now always open a new IO object, and close the previous one. This way the uploaded file will be reopened if it’s closed.
- 
Fixed possible encoding issues in Shrine::Storage::S3#uploadwhen filesize is unknown.
- 
The registered storage resolvers in the dynamic_storageplugin are now correctly inherited upon subclassing.
- 
The :fileMIME type analyzer fromdetermine_mime_typeplugin will now raise an explicitShrine::Errorwhen the subprocess from the shell command failed to be spawned.
- 
Attacher#data_uri=andAttacher#remote_url=in addition to""now also ignorenilvalues, instead of raising an exception.
Backwards compatibility¶ ↑
- 
The :storagesoption has been deprecated in thedownload_endpointplugin in favour of the newShrine::UploadedFile#download_urlmethod.
- 
The deprecation of assigning cached versions has been undone, as it can be a useful feature.