module Shrine::Plugins::DataUri::FileMethods

  1. lib/shrine/plugins/data_uri.rb

Methods

Public Instance

  1. base64
  2. data_uri

Public Instance methods

base64()

Returns contents of the file base64-encoded.

[show source]
    # File lib/shrine/plugins/data_uri.rb
144 def base64
145   binary = open { |io| io.read }
146   result = Base64.strict_encode64(binary)
147   binary.clear # deallocate string
148   result
149 end
data_uri()

Returns the data URI representation of the file.

[show source]
    # File lib/shrine/plugins/data_uri.rb
139 def data_uri
140   @data_uri ||= "data:#{mime_type || "text/plain"};base64,#{base64}"
141 end