module Shrine::Plugins::KitheDerivatives::InstanceMethods
Public Instance Methods
extract_metadata(io, derivative:nil, **context)
click to toggle source
Override to fix “filename” metadata to be something reasonable, regardless of what if anything was the filename of the IO being attached. shrine S3 will insist on setting a default content-disposition with this filename.
Calls superclass method
# File lib/shrine/plugins/kithe_derivatives.rb, line 38 def extract_metadata(io, derivative:nil, **context) result = super if derivative && context[:record] && result["mime_type"] extension = MiniMime.lookup_by_content_type(result["mime_type"] || "")&.extension || "bin" result["filename"] = "#{context[:record].friendlier_id}_#{derivative}.#{extension}" end result end