module Shrine::Plugins::DataUri

  1. lib/shrine/plugins/data_uri.rb

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

Methods

Public Class

  1. configure
  2. load_dependencies

Constants

BASE64_REGEXP = /;base64/  
CONTENT_SEPARATOR = /,/  
DATA_REGEXP = /data:/  
DEFAULT_CONTENT_TYPE = "text/plain"  
LOG_SUBSCRIBER = -> (event) do Shrine.logger.info "Data URI (#{event.duration}ms) – #{{ uploader: event[:uploader], }.inspect}" end  
MEDIA_TYPE_REGEXP = /[-\w.+]+\/[-\w.+]+(;[-\w.+]+=[^;,]+)*/  

Public Class methods

configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
[show source]
   # File lib/shrine/plugins/data_uri.rb
31 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
32   uploader.opts[:data_uri] ||= {}
33   uploader.opts[:data_uri].merge!(opts)
34 
35   # instrumentation plugin integration
36   uploader.subscribe(:data_uri, &log_subscriber) if uploader.respond_to?(:subscribe)
37 end
load_dependencies(uploader, *)
[show source]
   # File lib/shrine/plugins/data_uri.rb
27 def self.load_dependencies(uploader, *)
28   uploader.plugin :validation
29 end