Sha256: 1a4491cc09072637686239a44eda04b9ad37ad8c3c1fc71baa295586efd78d52
Contents?: true
Size: 930 Bytes
Versions: 39
Compression:
Stored size: 930 Bytes
Contents
# frozen_string_literal: true module Alchemy class AttachmentsController < BaseController before_action :load_attachment authorize_resource class: Alchemy::Attachment # sends file inline. i.e. for viewing pdfs/movies in browser def show response.headers['Content-Length'] = @attachment.file.size.to_s send_file( @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type, disposition: 'inline' } ) end # sends file as attachment. aka download def download response.headers['Content-Length'] = @attachment.file.size.to_s send_file( @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type } ) end private def load_attachment @attachment = Attachment.find(params[:id]) end end end
Version data entries
39 entries across 39 versions & 1 rubygems