Created
June 3, 2015 08:48
-
-
Save Agowan/12ced613d1d316244d16 to your computer and use it in GitHub Desktop.
Renaming files on response for expiring url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
class Report < ActiveRecord::Base | |
has_attached_file :file, :path => "/:statistic_report_root/:year/:id_partition.pdf" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReportsController < ApplicationController | |
def download | |
report = Report.find(params[:id]) | |
options = {expires: 100, :response_content_type => "application/vnd.ms-excel", response_content_disposition: "'attachment; filename=test.xls'"} | |
redirect_to report.pdf.s3_object.url_for(:read, options).to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment