Sha256: 2f21750a74e5ef1e3a53bb37af764380290f9aaad0002851f60bf34e701f472a

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

# frozen_string_literal: true

class DownloadsController < ApplicationController
  before_action :find_asset

  def show
    authorize!(:show, @asset)

    headers['X-Accel-Redirect'] = @asset.x_accel_url
    headers['Content-Disposition'] = "attachment; filename=\"#{@asset.filename}\""

    render nothing: true
  end

  private

  def find_asset
    @asset = Asset.find_klass(params[:type]).where(id: params[:id], data_file_name: params[:filename]).first
    raise ActiveRecord::RecordNotFound, 'File not found' if @asset.nil?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/controllers/downloads_controller.rb