Sha256: 830c32d01e236812d3caeed861057af9e18f9894c319a28a8c9c2a8a11dca776

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 Bytes

Contents

module Alchemy
  class AttachmentsController < BaseController

    filter_access_to [:show, :download], :attribute_check => true, :model => Alchemy::Attachment, :load_method => :load_attachment

    # sends file inline. i.e. for viewing pdfs/movies in browser
    def show
      send_data(
        @attachment.file.data,
        {
          :filename => @attachment.file_name,
          :type => @attachment.file_mime_type,
          :disposition => 'inline'
        }
      )
    end

    # sends file as attachment. aka download
    def download
      send_data(
        @attachment.file.data, {
          :filename => @attachment.file_name,
          :type => @attachment.file_mime_type
        }
      )
    end

  private

    def load_attachment
      @attachment = Attachment.where(:id => params[:id]).first
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alchemy_cms-2.6.3 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.6.2.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.6.2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.6.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.6.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.6.0.rc5 app/controllers/alchemy/attachments_controller.rb