Sha256: ab784ac529b10c701bfdd793c30b51ec89a1c12e996bc6c99d855d12245c5ecf

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 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.find(params[:id])
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alchemy_cms-2.5.0.rc3 app/controllers/alchemy/attachments_controller.rb