—
title: Shrine 2.17.0
New features
-
The
download_endpointplugin now accepts ad-hoc options when creating the endpoint instance, which override any plugin options.
rb Shrine.download_endpoint(disposition: "attachment")
-
The
Shrine::Attacher#assign_remote_urlmethod in theremote_urlplugin now accepts additional options forwarded toShrine#upload.
rb attacher.assign_remote_url(url, metadata: { "mime_type" => "text/plain" })
-
The
Shrine::Attacher#assign_data_urimethod has been added to thedata_uriplugin, which accepts additionalShrine#uploadoptions.
rb attacher.assign_data_uri(uri, metadata: { "filename" => "custom.txt" })
-
The
default_urlplugin now accepts a:hostoption for specifying the URL host.
“‘rb plugin :default_url, host: “example.com”
Attacher.default_url { “/#{name}/missing.png” } rb user.avatar_url #=> “
” “‘
Other improvements
-
The
derivation_endpointplugin now works correctly whenmovingplugin is loaded andupload: trueis set. -
The
Shrine.download_endpointobject is now compatible with the Rails router again (this was broken inShrine2.15.0). -
The
rack_responseplugin was in certain cases producingnil-chunks for the response body, which caused exceptions with some web servers. This has now been fixed. -
The
rack_responseplugin now stops retrieving file content that goes past the range specified in theRangeheader. This improves performance for storage classes that internally useDown::ChunkedIO. -
The
derivation_endpoint,rack_response, anddownload_endpointplugins now includeETagin the headers of responses, preventing theRack::ETagmiddleware from buffering the response body. -
Fixed inheritance of
processblocks in theprocessingplugin. Now addingprocessblocks in theShrinesubclass won't affect the superclass. -
Improved performance of
Shrine::Storage::FileSystem#deleteby switching fromDir.foreachtoDir.empty?. -
The
parsed_jsonplugin now accepts hashes with symbol keys. -
The
versionsplugin now accepts string version names inShrine::Attacher#url. -
The
versionsplugin now supports returning a hash of versions with string names inside theprocessblock. -
The
download_endpointplugin has been rewritten to use plain Rack, so Roda isn't a dependency anymore. -
The endpoint's
#inspectand#to_soutputs inupload_endpoint,presign_endpoint,download_endpoint, andderivation_endpointplugins have been simplified. Now therake routescommand output in Rails apps should be much more compact.
“‘rb # BEFORE: ImageUploader.upload_endpoint(:cache) #=> #<Shrine::Plugins::UploadEndpoint::App:0x00007f91bec17dc8 @max_size=nil, @rack_response=nil, @shrine_class=ImageUploader, @storage_key=:cache, @upload=nil, @upload_context=nil> ImageUploader.presign_endpoint(:cache) #=> #<Shrine::Plugins::PresignEndpoint::App:0x00007f91beca4ea8 @presign=nil, @presign_location=nil, @presign_options=nil, @rack_response=nil, @shrine_class=ImageUploader, @storage_key=:cache> ImageUploader.download_endpoint #=> #<Class:0x00007f91bed1fa90> ImageUploader.derivation_endpoint #=> #<Shrine::DerivationEndpoint:0x00007f91bed4c900 @options={}, @shrine_class=ImageUploader>
# AFTER: ImageUploader.upload_endpoint(:cache) #=> #<ImageUploader::UploadEndpoint(:cache)> ImageUploader.presign_endpoint(:cache) #=> #<ImageUploader::PresignEndpoint(:cache)> ImageUploader.download_endpoint #=> #<ImageUploader::DownloadEndpoint> ImageUploader.derivation_endpoint #=> #<ImageUploader::DerivationEndpoint> “‘
-
The
derivation_endpointplugin is now compatible with Rack 1.6. -
The
metadata_attributesplugin now preservesAttacher#assignmethod signature, by retaining the secondoptionsargument.
Backwards compatibility
-
The support for MRI 2.3 has been dropped.
-
The automatic filename fallback was removed from the
:marcelanalyzer indetermine_mime_typeplugin, as in some cases it caused MIME type to be incorrectly determined and could cause potential security issues. You can still opt in for it:
rb plugin :determine_mime_type, analyzer: :marcel, analyzer_options: { filename_fallback: true }
-
The
Shrine::Plugins::UploadEndpoint::Appclass from theupload_endpointplugin has been renamed toShrine::UploadEndpoint. The old constant will be removed inShrine3. -
The
Shrine::Plugins::PresignEndpoint::Appclass from thepresign_endpointplugin has been renamed toShrine::PresignEndpoint. The old constant will be removed inShrine3. -
The
Shrine::Plugins::DownloadEndpoint::Appclass is not aRodasubclass anymore, it's now a PORO whose instance responds to#call. This shouldn't affect your code unless you were calling Roda methods on that class. -
The plugin options of
upload_endpoint,presign_endpoint, anddownload_endpointare now internally stored in a different place inShrine.opts. This shouldn't affect your code unless you were accessing these options directly. -
The
Shrine::UrlSignerinternal class inderivation_endpointplugin has been updated. This shouldn't affect your code unless you were using/overriding that class.