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, line 170
def base64
  binary = open { |io| io.read }
  result = Base64.strict_encode64(binary)
  binary.clear # deallocate string
  result
end
data_uri ()

Returns the data URI representation of the file.

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