Module: FileEncoder

Defined in:
lib/mangopay/util/file_encoder.rb

Overview

Encodes files

Class Method Summary collapse

Class Method Details

.encode_base64(path) ⇒ String

Encodes a file to a Base64 string.

Parameters:

  • +path+ (String)

    path to the file to be encoded

Returns:

  • (String)

    the file as a Base64-encoded string



11
12
13
14
# File 'lib/mangopay/util/file_encoder.rb', line 11

def encode_base64(path)
  data = File.open(path, 'rb', &:read)
  Base64.strict_encode64 data
end