Class: DashamailTransactional::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/dashamail/utils.rb

Constant Summary collapse

MAX_FILENAME_LENGTH =
255

Class Method Summary collapse

Class Method Details

.build_attachment(file_path) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/dashamail/utils.rb', line 11

def build_attachment(file_path)
  validate_and_read_file(file_path) do |file_name, file_content|
    {
      name: truncate_filename(file_name),
      filebody: Base64.strict_encode64(file_content)
    }
  end
end

.build_inline(file_path, cid) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/dashamail/utils.rb', line 20

def build_inline(file_path, cid)
  validate_and_read_file(file_path) do |file_name, file_content|
    {
      mime_type: MIME::Types.type_for(file_path).first&.to_s || 'application/octet-stream',
      filename: truncate_filename(file_name),
      body: Base64.strict_encode64(file_content),
      cid: cid
    }
  end
end