—
title: Shrine
1.3.0¶ ↑
New features¶ ↑
-
Added
:namespace
option to pretty_location plugin for including the model namespace into the location. -
Addded
:include_error
option to remote_url plugin which gives you access to the download error instance when generating the error message. -
Added
<attachment>_cached?
and<attachment>_stored?
to migration_helpers for easier handling of uploading logic in ORM hooks:
class Photo < Sequel::Model def before_save if column_changed?(:image) && image_stored? # promote # ... end super end end
Other improvements¶ ↑
-
Fixed uploading an S3 file making an additional unneeded GET request in addition to the S3 COPY request.
-
When the model with an attachment is namespaced, the namespace isn't included in the location anymore when using the pretty_location plugin.
-
Dumped Down version to 2.0.0 to fix downloading files from URLs which have "[]" characters in them.
-
The IO is now rewinded even if FastImage fails to extract dimensions from the IO
-
The IO is now rewinded when using MimeMagic to extract the MIME type.
-
When uploading a
Shrine::UploadedFile
, the default location generator will first look for the extension in#id
before looking at#original_filename
. -
The remote_url plugin now returns separate error messsages when file wasn't found and when the file was too large.
-
Fixed promoting raising an error if the record got deleted before promoting finished
-
UploadedFile#original_filename
,#size
and#content_type
now returnnil
when corresponding metadata keys are missing instead of raising aKeyError
. -
Fixed errors being able to accumulate on the record object when errors occur in data_uri and remote_url plugins.
-
The "metadata" key isn't required anymore when instantiating a
Shrine::UploadedFile
. -
The top-level key-values aren't cached anymore when instantiating a
Shrine::UploadedFile
, which means that#id
,#storage_key
and#metadata
will now pick up any mutations on the data hash. -
Removed a deprecation warning in the S3 storage which occurs when AWS credentials are inferred implicitly.
-
The extracted metadata is now accessible inside
Shrine#generate_location
via the:metadata
key in thecontext
hash. -
Shrine#upload
doesn’t mutate the given context hash anymore. -
Shrine::Attacher#backup_file
from the backup plugin doesn’t modify the inputUploadedFile
anymore.
Deprecations¶ ↑
-
The keep_location plugin is deprecated, as the same behaviour can easily be achieved by overriding
Shrine#generate_location
:
class ImageUploader < Shrine def generate_location(io, context) if io.is_a?(UploadedFile) && context[:phase] == :store io.id else super end end end