—
title: Shrine 3.5.0¶ ↑
New features¶ ↑
-
The website has been migrated to Docusaurus v2. :sparkles:
-
The
:signeroption has been added to thederivation_endpointplugin, 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_partsoption 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
:encodingoption 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, becauseShrinewould 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 Requestresponse when the serialized file component is invalid. -
The
derivativesplugin now supports passingmutex: falseoption to disable usage of a mutex. This makes theShrine::Attacherobject marshallable, which should enable usingMarshal.dumpandMarshal.loadon model instances with attachments. This should be safe unless you're adding derivatives on the same attacher object concurrently. -
When loading the
derivativesplugin withversions_compatibility: true, this setting doesn't leak to other uploaders anymore. Previously if other uploaders would loadderivativesplugin 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
:taggingupload option when promoting from temporary to permanent storage, and have it take effect. -
The
UploadedFile#urlmethod doesn't call the obsoleteURI.regexpmethod anymore, which should avoid warnings. -
The
infer_extensionplugin now definesinfer_extensioninstance 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 “‘