Method: Upcloudify::S3#email

Defined in:
lib/upcloudify.rb

#email(email_address, filename, attachment, options = { suffix: "", expiration: (Date.today + 7).to_time, from: 'upcloudify', subject: 'your file is attached', body: 'your report is linked ' }) ⇒ Object

Uploads a file to S3 and emails a link to the file. Returns nothing.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/upcloudify.rb', line 83

def email(email_address,
  filename,
  attachment,
  options = {
    suffix: "",
    expiration: (Date.today + 7).to_time,
    from: 'upcloudify',
    subject: 'your file is attached',
    body: 'your report is linked '
  }
)

  suffix = options[:suffix]
  expiration = options[:expiration]
  file = upload((filename.to_s + suffix.to_s), attachment)

  Pony.mail to: email_address,
    from: options[:from],
    subject: options[:subject],
    body: (options[:body] || '') + file.url(expiration) + ' '

end