You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
747 B
27 lines
747 B
class CsvDownloadsController < ApplicationController |
|
before_action :authenticate_user! |
|
|
|
def show |
|
@csv_download = CsvDownload.find(params[:id]) |
|
authorize @csv_download |
|
|
|
return render "errors/download_link_expired" if @csv_download.expired? |
|
end |
|
|
|
def download |
|
csv_download = CsvDownload.find(params[:id]) |
|
authorize csv_download |
|
|
|
return render "errors/download_link_expired" if csv_download.expired? |
|
|
|
downloader = Csv::Downloader.new(csv_download:) |
|
|
|
if Rails.env.development? |
|
downloader.call |
|
send_file downloader.path, filename: csv_download.filename, type: "text/csv" |
|
else |
|
presigned_url = downloader.presigned_url |
|
redirect_to presigned_url, allow_other_host: true |
|
end |
|
end |
|
end
|
|
|