Sha256: bfa5aeba54564162f8361e7998a37bd8fe8f5a35ace721e328039fb346a82e75

Contents?: true

Size: 870 Bytes

Versions: 7

Compression:

Stored size: 870 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_file(
        @attachment.public_filename,
        {
          :name => @attachment.filename,
          :type => @attachment.content_type,
          :disposition => 'inline'
        }
      )
    end

    # sends file as attachment. aka download
    def download
      send_file(
        @attachment.full_filename, {
          :name => @attachment.filename,
          :type => @attachment.content_type,
          :disposition => 'attachment'
        }
      )
    end

  private

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

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alchemy_cms-2.5.3.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.3 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.2.2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.2.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.0 app/controllers/alchemy/attachments_controller.rb