—
title: Shrine
2.11.0¶ ↑
New features¶ ↑
-
Shrine::UploadedFile#stream
has been added for streaming the uploaded content to a writable destination.
uploaded_file.stream(StringIO.new) # or uploaded_file.stream("/path/to/destination")
-
Shrine.with_file
has been added for temporarily converting an IO-like object into a file. This is useful when wanting to extract metadata using an analyzer which requires the source file to be on disk.
add_metadata do |io, context| movie = Shrine.with_file(io) { |file| FFMPEG::Movie.new(file.path) } { "duration" => movie.duration, "bitrate" => movie.bitrate, "resolution" => movie.resolution, "frame_rate" => movie.frame_rate } end
-
The
upload_endpoint
plugin now accepts theContent-MD5
request header, in which case it will verify the provided checksum. -
Shrine::Storage::S3#presign
now acceptsmethod: :put
for changing from a POST to a PUT presigned URL. PUT presigned URLs are generally preferred as they support more parameters, such as:content_md5
for specifying the checksum.
Other improvements¶ ↑
-
Shrine::UploadedFile#download
will now reuse an already opened file, and in this case will simply rewind it after it’s finished. -
The
:mini_magick
and:ruby_vips
dimensions analyzers now silently fail on processing errors, to allow validations to be reached when invalid file is attached. -
The
#presign
storage method can now return a Hash. This means it's not required for result to be wrapped in aStruct
orOpenStruct
anymore. -
The
Shrine::Storage::S3#presign
now also returns a:method
value indicating the HTTP verb that needs to be used for the direct upload. -
The bucket name is not removed from S3 URL path anymore when both
:host
and:force_path_style
are set inShrine::Storage::S3#url
.
Regressions¶ ↑
-
The MIME type is now correctly determined on empty files for
:mime_types
and:mini_mime
analyzers. This regression was introduced inShrine
2.7.0.
Backwards compatibility¶ ↑
-
The
direct_upload
plugin has been deprecated in favour ofupload_endpoint
andpresign_endpoint
plugins. Thedirect_upload
plugin will be removed inShrine
3. -
Storage#presign
returning an object that doesn’t respond to#to_h
is now deprecated, the support for these objects will be removed inShrine
3. -
Shrine::Storage::S3#presign
now returns aStruct
instead of anAws::S3::PresignedPost
object. Any applications relying on any methods other than#url
and#fields
will have to update their code.