Last Update: 2023-07-30 18:26:06 +0200

title: Shrine 2.11.0

New features

  • Shrine::UploadedFile#stream has been added for streaming the uploaded content to a writable destination.

# or
  • 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 }
  • The upload_endpoint plugin now accepts the Content-MD5 request header, in which case it will verify the provided checksum.

  • Shrine::Storage::S3#presign now accepts method: :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 a Struct or OpenStruct 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 in Shrine::Storage::S3#url.


  • The MIME type is now correctly determined on empty files for :mime_types and :mini_mime analyzers. This regression was introduced in Shrine 2.7.0.

Backwards compatibility

  • The direct_upload plugin has been deprecated in favour of upload_endpoint and presign_endpoint plugins. The direct_upload plugin will be removed in Shrine 3.

  • Storage#presign returning an object that doesn’t respond to #to_h is now deprecated, the support for these objects will be removed in Shrine 3.

  • Shrine::Storage::S3#presign now returns a Struct instead of an Aws::S3::PresignedPost object. Any applications relying on any methods other than #url and #fields will have to update their code.