Method: FileAttachmentsController#download

Defined in:
app/controllers/file_attachments_controller.rb

#downloadObject



44
45
46
47
48
49
50
# File 'app/controllers/file_attachments_controller.rb', line 44

def download
  file_attachment = FileAttachment.find(params[:id])
  file_itself     = File.open(file_attachment.full_path, 'r')
  logger.debug("FILE ATTACHMENT INFO: #{file_attachment.inspect}")
  logger.debug("FILE INFO: #{file_itself.inspect}")
  send_data(file_itself.read, :filename => File.basename(file_itself.path), :stream => true, :buffer_size => 1.megabyte)
end