module Shrine::Plugins::DataUri::ClassMethods

  1. lib/shrine/plugins/data_uri.rb

Methods

Public Instance

  1. data_uri

Public Instance methods

data_uri(uri, filename: nil)

Parses the given data URI and creates an IO object from it.

io = Shrine.data_uri("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA")
io #=> #<Shrine::Plugins::DataUri::DataFile>
io.content_type #=> "image/png"
io.size         #=> 21
io.read         # decoded content
[show source]
   # File lib/shrine/plugins/data_uri.rb
61 def data_uri(uri, filename: nil)
62   instrument_data_uri(uri) do
63     info = parse_data_uri(uri)
64     create_data_file(info, filename: filename)
65   end
66 end