module Shrine::Plugins::InferExtension

  1. lib/shrine/plugins/infer_extension.rb

Documentation can be found on shrinerb.com/docs/plugins/infer_extension

Methods

Public Class

  1. configure

Constants

LOG_SUBSCRIBER = -> (event) do Shrine.logger.info "Extension (#{event.duration}ms) – #{{ mime_type: event[:mime_type], uploader: event[:uploader], }.inspect}" end  

Public Class methods

configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
[show source]
   # File lib/shrine/plugins/infer_extension.rb
16 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
17   uploader.opts[:infer_extension] ||= { inferrer: :mini_mime }
18   uploader.opts[:infer_extension].merge!(opts)
19 
20   # instrumentation plugin integration
21   uploader.subscribe(:extension, &log_subscriber) if uploader.respond_to?(:subscribe)
22 end