Method: MailsViewer::HomeController#attachment

Defined in:
app/controllers/mails_viewer/home_controller.rb

#attachmentObject



46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/mails_viewer/home_controller.rb', line 46

def attachment
  if @filename
    mail = Mail.read(@filename)
    attachment = mail.attachments[params[:attachment]]

    if attachment
      send_data attachment.body.decoded, filename: params[:attachment], type: attachment.content_type and return
    end
  end

  head :not_found
end