—
title: Shrine 2.0.0¶ ↑
Backwards compatibility¶ ↑
- 
Metadata and upload options are now differently passed to storages, so the new signature of #uploadand#movemethods on the storage class should be:
def upload(io, id, shrine_metadata: {}, **upload_options) # ... end def move(io, id, shrine_metadata: {}, **upload_options) # ... end
- 
The Shrine::Confirmfunctionality has been removed from storages' specification, storages should updateclear!to remove the confirmation.
- 
The :delegateoption in migration_helpers now defaults to false.
- 
The migration_helpers plugin has been deprecated, Shrine::Attacher#cached?andShrine::Attacher#stored?have been moved to base functionality.
- 
The "background_helpers" alias for the backgrounding plugin has been deprecated and will be removed in Shrine3.
- 
In backgrounding plugin the "attachment" key has been renamed to "name", and "uploaded_file" has been renamed to "attachment" in the data hash in background job argument. 
- 
Shrine::Attacher.promoteandShrine::Attacher.deletefrom backgrounding plugin now return aShrine::Attacherinstance instead of the model instance.
- 
The moving plugin doesn't delete files that aren't movable anymore. You should use delete_raw and/or delete_promoted plugins for this functionality. 
- 
The deprecated "delete_uploaded" alias for delete_raw plugin has been removed. 
- 
The deprecated "restore_cached" alias for restore_cached_data plugin has been removed. 
- 
The deprecated keep_location plugin has been removed. 
- 
The deprecated :subdirectoryoption in FileSystem storage has been removed.
- 
The deprecated Shrine#default_urlhas been removed (specifying a default URL by overriding#default_urlon the uploader), the default_url plugin should be used instead.
- 
The deprecated Shrine.direct_endpointalias forShrine::UploadEndpointin direct_upload plugin has been removed.
- 
The :presignoption in direct_upload plugin cannot be used for specifying presign options anymore;:presign_optionsshould be used instead.
- 
Shrine::Attacher#setand#assignmethods don’t return the assigned uploaded file anymore.
- 
Shrine::Attacher#delete!doesn’t spawn a background job anymore with backgrounding plugin, plugin writers should switch to#_deleteinstead.
- 
The phases when files are internally deleted have been renamed. 
- 
Shrinedoesn’t officially support Rubinius anymore.
New plugins¶ ↑
- 
The shrine-reform plugin has been released, which makes Shrineattachments work with Reform objects.
- 
The shrine-mongoid plugin has been released, which makes Shrineattachments work with Mongoid models.
New storages¶ ↑
- 
The shrine-memory storage has been released, which saves uploaded files in memory (useful in tests). 
New features¶ ↑
- 
The built-in analyzers can now be used when implementing a custom MIME type analyzer in determine_mime_type plugin. 
plugin :determine_mime_type, analyzer: ->(io, analyzers) do analyzers[:mimemagic].call(io) || analyzers[:file].call(io) end
- 
The built-in analyzers can now be used when implementing a custom dimensions analyzer in store_dimensions plugin. 
plugin :store_dimensions, analyzer: ->(io, analyzers) do dimensions = analyzers[:filemagic].call(io) dimensions || MiniMagick::Image.new(io).dimensions end
- 
Shrine::Attacher#cache!,#store!and#delete!are now public (they are wrappers forShrine#uploadandShrine#deletewith context passed in).
- 
Shrine::Attacher#_deletehas been added as a wrapper around#delete!, which the backgrounding plugin overrides and makes aynchronous. This nicely complements theShrine::Attacher#_promotewrapper around#promote.
Other improvements¶ ↑
- 
Shrinenow prints a security warning when determine_mime_type plugin isn’t loaded.
- 
Don't error in determine_mime_type with :mimemagicanalyzer when MimeMagic cannot determine MIME of the file.
- 
When :hostis given to S3 storage, URLs will now include the query parameters, unless:publicis given, just like without:host.
- 
The Down version has been bumped to 2.2.0, which means the remote_url plugin now follows redirects (maximum of 2 redirects by default). 
- 
The Shrine::Attacher#_promoteandShrine::Attacher#promotenow have the same generalized method signature.
- 
The restore_cached_data plugin functionality won't get triggered anymore when form is submitted with already saved cached attachmnet (e.g. due to background processing). 
- 
The restore_cached_data plugin now doesn't check anymore if the cached file exists (which saves an HTTP request with remote storages). 
- 
The download_endpoint now makes only one HTTP request when downloading files from remote storages. 
- 
The activerecord plugin now allows attachment modules to be included in non-ActiveRecord models. 
- 
The sequel plugin now allows attachment modules to be included in non-Sequel models. 
- 
Plugin options are now persisted when reapplying plugins. 
Shrine.plugin :download_endpoint, storages: [:store], prefix: "/downloads", disposition: "inline" class DocumentUploader < Shrine # all other options above will be persisted plugin :download_endpoint, disposition: "attachment" end
- 
The :include_errorhas been removed from remote_url plugin, the error will now be included in the second argument depending on lambda's arity.
- 
The dynamic_storage plugin doesn't cache the instantiated storages anymore, which enables use cases like storing storage definitions in the database. 
- 
The determine_mime_type plugin with :fileanalyzer now handles filenames that start with a dash ("-").
- 
Shrine::Attachernow allocates less strings.