Here is my code -
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
-> this is the method which is saving the file into folder I need to read the size of the file under this folder.
#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
Any help will be appreciated. Thank you.
Aucun commentaire:
Enregistrer un commentaire