Method: SendGrid::Mail#add_attachment

Defined in:
lib/sendgrid/mail.rb

#add_attachment(path, name = nil) ⇒ Object



93
94
95
96
97
98
# File 'lib/sendgrid/mail.rb', line 93

def add_attachment(path, name = nil)
  mime_type = MimeMagic.by_path(path)
  file = Faraday::UploadIO.new(path, mime_type)
  name ||= File.basename(file)
  attachments << {file: file, name: name}
end