—
title: Shrine
3.5.0¶ ↑
New features¶ ↑
-
The website has been migrated to Docusaurus v2. :sparkles:
-
The
:signer
option has been added to thederivation_endpoint
plugin, for when you want to use custom URL signing. This is useful when using:expires_in
, and wanting to have expiring URLs work with CDN caching.
“‘rb require “aws-sdk-cloudfront” signer = Aws::CloudFront::UrlSigner.new(key_pair_id: “…”, private_key: “…”)
plugin :derivation_endpoint, expires_in: 90, signer: -> (url, expires_in:) do signer.signed_url(url, expires: Time.now.to_i + expires_in) end “‘
-
The S3 storage now supports
:max_multipart_parts
option for specifying the maximum number of concurrent parts in which a large file will get uploaded. This number defaults to10_000
.
rb Shrine::Storage::S3.new(max_multipart_parts: 1000, ...)
-
The
:encoding
option can now be passed toS3#open
, which is applied to downloaded chunks.
rb io = uploaded_file.open(encoding: Encoding::UTF_8) csv = CSV.new(io) # ...
Other improvements¶ ↑
-
Passing a boolean value to the
#remove_attachment=
setter now works on Ruby 3.2. Previously this would raise an error, becauseShrine
would try to call=~
on it, butObject#=~
method has been removed in Ruby 3.2. -
When duplicating a model instance, the duplicated attacher now references the duplicated model instance instead of the original one.
-
The download endpoint now returns a
400 Bad Request
response when the serialized file component is invalid. -
The
derivatives
plugin now supports passingmutex: false
option to disable usage of a mutex. This makes theShrine::Attacher
object marshallable, which should enable usingMarshal.dump
andMarshal.load
on model instances with attachments. This should be safe unless you're adding derivatives on the same attacher object concurrently. -
When loading the
derivatives
plugin withversions_compatibility: true
, this setting doesn't leak to other uploaders anymore. Previously if other uploaders would loadderivatives
plugin without this option, versions compatibility would still get enabled for them. This change also fixes behavior on JRuby. -
When S3 storage copies files, the AWS tag are not inherited anymore. This allows passing the
:tagging
upload option when promoting from temporary to permanent storage, and have it take effect. -
The
UploadedFile#url
method doesn't call the obsoleteURI.regexp
method anymore, which should avoid warnings. -
The
infer_extension
plugin now definesinfer_extension
instance method (in addition to class method) on the uploader for convenience, so that it can be easily called at the uploader instance level.
“‘rb class MyUploader < Shrine
plugin :infer_extension
def generate_location(io, metadata:, **) extension = infer_extension(metadata["mime_type"]) # ... end
end “‘