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

title: Shrine 2.1.0


  • The versions plugin doesn't require the :names option anymore.

  • The restore_cached_data plugin will now download only a small portion of the file needed for extracting metadata (after which it will terminate the connection). Previously the whole file was always downloaded. To get this you need to update your storage gem.

  • When enforcing that the input is an IO-like object Shrine doesn't check method arity anymore, only if the object responds to that method. This means that Shrine now properly works with objects like Rack::Test::UploadedFile, which use #method_missing to delegate to the underlying object.

  • Fixed a load order bug with parallelize and logging plugins, where loading them in this order would make the thread pool join outside of the logging block, making the logs show an instantaneous duration instead of the actual duration.

  • The file command from the determine_mime_type plugin is now executed in the same way for files as for other IO objects.

  • Increase the amount of bytes read from the IO in determine_mime_type when using :file or :filemagic analyzers, which might make the recognize some MIME types that they haven't before.

Backwards compatibility

  • Generating versions in :cache phase is now deprecated, for better security.

  • The #cached_<attachment>_data= method that comes from the cached_attachment_data plugin is now deprecated. The reason for this is that the following "recommended" usage actually produces bugs when image is invalid:

form_for @photo do |f|
  f.hidden_field :cached_image_data
  f.file_filed :image

The recommended and correct way now to build forms is by keeping the #<attachment>= setter:

form_for @photo do |f|
  f.hidden_field :image, value: @photo.cached_image_data, id: nil
  f.file_filed :image
  • The restore_cached_data now sends the Shrine::UploadedFile to #extract_metadata, instead of the result of Storage#open.

  • Storages which use #stream should switch to Down.open for remote files, or the generic Down::ChunkedIO in other cases.