Sha256: 39fd866998b1cba51471d3d1153c0bb135cb75d1369175029dd17f70b60b31c4

Contents?: true

Size: 586 Bytes

Versions: 9

Compression:

Stored size: 586 Bytes

Contents

module CMS
  class AttachmentsController < RailsAdminCMS::Config.parent_controller
    before_action :authenticate_admin_user!

    def show
      name, format = params[:file].sub(/\?.+$/, ''), params[:format]
      file_name = "#{name}.#{format}"
      content_type = Mime::Type.lookup_by_extension(format)

      send_file(
        "#{Rails.root}/private/attachments/#{params[:directory]}/#{file_name}",
        type: content_type,
        filename: file_name,
        disposition: 'inline',
        x_sendfile: !Rails.env.development?,
        stream: true
      )
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_admin_cms-0.1.1 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.9 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.7 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.6 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.5 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.4 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.3 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.2 app/controllers/cms/attachments_controller.rb
rails_admin_cms-0.0.1 app/controllers/cms/attachments_controller.rb