Sha256: 138b64154538a6c14281b51ce1a3272d701d2575f511670b6626c38e533a70eb
Contents?: true
Size: 518 Bytes
Versions: 13
Compression:
Stored size: 518 Bytes
Contents
require 'marcel' require 'base64' module Chronicle module ETL module Utils # Utility methods for dealing with binary files module BinaryAttachments def self.filename_to_base64(filename:, mimetype: nil) mimetype = mimetype || guess_mimetype(filename: filename) "data:#{mimetype};base64,#{Base64.strict_encode64(File.read(filename))}" end def self.guess_mimetype(filename:) Marcel::MimeType.for(filename) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems