Sha256: 06e4e9d31f096c42e398d8105b8639e13a0871349aae743d655847c664095a84

Contents?: true

Size: 760 Bytes

Versions: 27

Compression:

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

  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.3 app/controllers/alchemy/attachments_controller.rb
lc_alchemy_cms-3.2.1 app/controllers/alchemy/attachments_controller.rb
lc_alchemy_cms-3.2.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.2.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.2.0.rc1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.2.0.beta app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.0.4 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.rc3 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.rc2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.rc1 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.beta6 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.beta5 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.beta4 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.0.3 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.beta3 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.beta2 app/controllers/alchemy/attachments_controller.rb
alchemy_cms-3.1.0.beta1 app/controllers/alchemy/attachments_controller.rb