Class: LetterOpenerWeb::S3Message

Inherits:
LetterOpener::Message
  • Object
show all
Defined in:
app/models/letter_opener_web/s3_message.rb

Instance Method Summary collapse

Instance Method Details

#renderObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/letter_opener_web/s3_message.rb', line 5

def render
  mail.attachments.each do |attachment|
    filename = attachment_filename(attachment)

    LetterOpenerWeb.aws_client.put_object(
      bucket: LetterOpenerWeb.config.aws_bucket,
      key: "#{@location}/attachments/#{filename}",
      body: attachment.body.raw_source
    )

    @attachments << [attachment.filename, "attachments/#{filename}"]
  end

  LetterOpenerWeb.aws_client.put_object(
    bucket: LetterOpenerWeb.config.aws_bucket,
    key: "#{@location}/#{type}.html",
    body: ERB.new(template).result(binding)
  )
end