这是我的代码 -
file_name = "#{downloaded_file_name}_#{Time.now.strftime("%Y%m%d%H%M%S")}.pdf"
result, pdf_report = ReportFullStores.get_order_receipts(customer, input_data)
#call method
schedule_report.generate_schedule_report(file_name, pdf_report)
#here before sending the file into mailer I want to check the file size.
# If file size is greater than 20 mb
#code here
# else
#code here
#end
#save file in public/scheduled_reports folder xls / pdf or both
def generate_schedule_report(file_name, report_data)
#then save file to public folder
save_path = Rails.root.join('public/scheduled_reports',file_name)
File.open(save_path, 'wb') do |file|
file << report_data
end
end
任何帮助将不胜感激。 谢谢。