—
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) #=> # AFTER: ImageUploader.upload_endpoint(:cache) #=> The The The support for MRI 2.3 has been dropped. The automatic filename fallback was removed from the The The The The plugin options of The derivation_endpoint plugin is now compatible with Rack 1.6.metadata_attributes plugin now preserves Attacher#assign method signature, by retaining the second options argument.Backwards compatibility¶ ↑
:marcel analyzer in determine_mime_type plugin, 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 } Shrine::Plugins::UploadEndpoint::App class from the upload_endpoint plugin has been renamed to Shrine::UploadEndpoint. The old constant will be removed in Shrine 3.Shrine::Plugins::PresignEndpoint::App class from the presign_endpoint plugin has been renamed to Shrine::PresignEndpoint. The old constant will be removed in Shrine 3.Shrine::Plugins::DownloadEndpoint::App class is not a Roda subclass 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.upload_endpoint, presign_endpoint, and download_endpoint are now internally stored in a different place in Shrine.opts. This shouldn’t affect your code unless you were accessing these options directly.Shrine::UrlSigner internal class in derivation_endpoint plugin has been updated. This shouldn’t affect your code unless you were using/overriding that class.