Module: Shrine::Plugins::DataUri
- Defined in:
- lib/shrine/plugins/data_uri.rb
Overview
Documentation lives in [doc/plugins/data_uri.md] on GitHub.
[doc/plugins/data_uri.md]: github.com/shrinerb/shrine/blob/master/doc/plugins/data_uri.md
Defined Under Namespace
Modules: AttacherMethods, AttachmentMethods, ClassMethods, FileMethods Classes: ParseError
Constant Summary collapse
- DATA_REGEXP =
/data:/
- MEDIA_TYPE_REGEXP =
/[-\w.+]+\/[-\w.+]+(;[-\w.+]+=[^;,]+)*/
- BASE64_REGEXP =
/;base64/
- CONTENT_SEPARATOR =
/,/
- DEFAULT_CONTENT_TYPE =
"text/plain"
- LOG_SUBSCRIBER =
-> (event) do Shrine.logger.info "Data URI (#{event.duration}ms) – #{{ uploader: event[:uploader], }.inspect}" end
Class Method Summary collapse
Class Method Details
.configure(uploader, opts = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shrine/plugins/data_uri.rb', line 29 def self.configure(uploader, opts = {}) uploader.opts[:data_uri] ||= { log_subscriber: LOG_SUBSCRIBER } uploader.opts[:data_uri].merge!(opts) if uploader.opts[:data_uri][:filename] Shrine.deprecation("The :filename option is deprecated for the data_uri plugin, and will be removed in Shrine 3. Use the infer_extension plugin instead.") end # instrumentation plugin integration if uploader.respond_to?(:subscribe) uploader.subscribe(:data_uri, &uploader.opts[:data_uri][:log_subscriber]) end end |