—
title: Shrine 2.11.0¶ ↑
New features¶ ↑
-
Shrine::UploadedFile#streamhas 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_filehas 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_endpointplugin now accepts theContent-MD5request header, in which case it will verify the provided checksum. -
Shrine::Storage::S3#presignnow acceptsmethod: :putfor changing from a POST to a PUT presigned URL. PUT presigned URLs are generally preferred as they support more parameters, such as:content_md5for specifying the checksum.
Other improvements¶ ↑
-
Shrine::UploadedFile#downloadwill now reuse an already opened file, and in this case will simply rewind it after it’s finished. -
The
:mini_magickand:ruby_vipsdimensions analyzers now silently fail on processing errors, to allow validations to be reached when invalid file is attached. -
The
#presignstorage method can now return a Hash. This means it's not required for result to be wrapped in aStructorOpenStructanymore. -
The
Shrine::Storage::S3#presignnow also returns a:methodvalue 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
:hostand:force_path_styleare set inShrine::Storage::S3#url.
Regressions¶ ↑
-
The MIME type is now correctly determined on empty files for
:mime_typesand:mini_mimeanalyzers. This regression was introduced inShrine2.7.0.
Backwards compatibility¶ ↑
-
The
direct_uploadplugin has been deprecated in favour ofupload_endpointandpresign_endpointplugins. Thedirect_uploadplugin will be removed inShrine3. -
Storage#presignreturning an object that doesn’t respond to#to_his now deprecated, the support for these objects will be removed inShrine3. -
Shrine::Storage::S3#presignnow returns aStructinstead of anAws::S3::PresignedPostobject. Any applications relying on any methods other than#urland#fieldswill have to update their code.