—
title: Shrine
2.17.0¶ ↑
New features¶ ↑
-
The
download_endpoint
plugin 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_url
method in theremote_url
plugin now accepts additional options forwarded toShrine#upload
.
rb attacher.assign_remote_url(url, metadata: { "mime_type" => "text/plain" })
-
The
Shrine::Attacher#assign_data_uri
method has been added to thedata_uri
plugin, which accepts additionalShrine#upload
options.
rb attacher.assign_data_uri(uri, metadata: { "filename" => "custom.txt" })
-
The
default_url
plugin now accepts a:host
option 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_endpoint
plugin now works correctly whenmoving
plugin is loaded andupload: true
is set. -
The
Shrine.download_endpoint
object is now compatible with the Rails router again (this was broken inShrine
2.15.0). -
The
rack_response
plugin was in certain cases producingnil
-chunks for the response body, which caused exceptions with some web servers. This has now been fixed. -
The
rack_response
plugin now stops retrieving file content that goes past the range specified in theRange
header. This improves performance for storage classes that internally useDown::ChunkedIO
. -
The
derivation_endpoint
,rack_response
, anddownload_endpoint
plugins now includeETag
in the headers of responses, preventing theRack::ETag
middleware from buffering the response body. -
Fixed inheritance of
process
blocks in theprocessing
plugin. Now addingprocess
blocks in theShrine
subclass won't affect the superclass. -
Improved performance of
Shrine::Storage::FileSystem#delete
by switching fromDir.foreach
toDir.empty?
. -
The
parsed_json
plugin now accepts hashes with symbol keys. -
The
versions
plugin now accepts string version names inShrine::Attacher#url
. -
The
versions
plugin now supports returning a hash of versions with string names inside theprocess
block. -
The
download_endpoint
plugin has been rewritten to use plain Rack, so Roda isn’t a dependency anymore. -
The endpoint’s
#inspect
and#to_s
outputs inupload_endpoint
,presign_endpoint
,download_endpoint
, andderivation_endpoint
plugins have been simplified. Now therake routes
command 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.