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 the- Content-MD5request header, in which case it will verify the provided checksum.
- Shrine::Storage::S3#presignnow accepts- method: :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 a- Structor- OpenStructanymore.
- 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 in- Shrine::Storage::S3#url.
Regressions
- The MIME type is now correctly determined on empty files for :mime_typesand:mini_mimeanalyzers. This regression was introduced in Shrine 2.7.0.
Backwards compatibility
- The - direct_uploadplugin has been deprecated in favour of- upload_endpointand- presign_endpointplugins. The- direct_uploadplugin will be removed in Shrine 3.
- Storage#presignreturning an object that doesn't respond to- #to_his now deprecated, the support for these objects will be removed in Shrine 3.
- Shrine::Storage::S3#presignnow returns a- Structinstead of an- Aws::S3::PresignedPostobject. Any applications relying on any methods other than- #urland- #fieldswill have to update their code.