Sha256: b35381e63cd95ffda536f5e1fe562a8ab028ef50b4132d262a5969075e1f0b30

Contents?: true

Size: 537 Bytes

Versions: 9

Compression:

Stored size: 537 Bytes

Contents

module CMS
  class FilesController < RailsAdminCMS::Config.parent_controller
    def show
      file_path = Viewable::Link.find(params[:id]).file
      file_name = File.basename(file_path)
      ext = File.extname(file_name).sub('.', '')
      content_type = Mime::Type.lookup_by_extension(ext)

      send_file(
        "#{Rails.root}/public#{file_path}",
        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/files_controller.rb
rails_admin_cms-0.0.9 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.7 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.6 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.5 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.4 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.3 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.2 app/controllers/cms/files_controller.rb
rails_admin_cms-0.0.1 app/controllers/cms/files_controller.rb