Sha256: 601cdbe5eaf85fce801340bc38798a2b0ad2b589d36806d4efa4623aed7eb40a

Contents?: true

Size: 865 Bytes

Versions: 13

Compression:

Stored size: 865 Bytes

Contents

module Alchemy
  class AttachmentsController < Alchemy::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.find(params[:id])
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
alchemy_cms-2.5.0.b9 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.3.2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.4.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.0.b5 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.5.0.b2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.4.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.4.rc4 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.4.rc2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.4.rc1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.3.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.4.beta2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.3.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-2.3.rc5 app/controllers/alchemy/attachments_controller.rb