Sha256: 8bd9573457daf2ff0b0625874635b30c7af383c58c6491cf810edf0d9efcd7fe

Contents?: true

Size: 358 Bytes

Versions: 3

Compression:

Stored size: 358 Bytes

Contents

require 'base64'

# Encodes files
module FileEncoder
  class << self

    # Encodes a file to a Base64 string.
    #
    # @param +path+ [String] path to the file to be encoded
    # @return [String] the file as a Base64-encoded string
    def encode_base64(path)
      data = File.open(path, 'rb', &:read)
      Base64.strict_encode64 data
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mangopay-v4-4.1.0 lib/mangopay/util/file_encoder.rb
mangopay-v4-4.0.2 lib/mangopay/util/file_encoder.rb
mangopay-v4-4.0.1 lib/mangopay/util/file_encoder.rb