Sha256: ffbf89a1549af79c6e338dd4fba4a3b4ced8c60cda690d483c7309e4cf5b1608

Contents?: true

Size: 759 Bytes

Versions: 13

Compression:

Stored size: 759 Bytes

Contents

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
      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
      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

13 entries across 13 versions & 1 rubygems

Version Path
alchemy_cms-3.5.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.4.2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.5.0.rc2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.5.0.rc1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.4.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.3.3 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.3.2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.4.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.4.0.rc1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.3.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.3.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.3.0.rc2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.3.0.rc1 app/controllers/alchemy/attachments_controller.rb