diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 1f970b217..2e06fac28 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -26,10 +26,11 @@ class TestController < ApplicationController folder = "#{Rails.root}/files" input_filename = files_path zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip" - + Rails.logger.info "================================================================================================================================================================================================================================================================================================================================================================================================#{zipfile_name}" + Dir.mkdir(File.dirname(zipfile_name)) if File.exist?(File.dirname(zipfile_name)) Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| - zipfile.add(filename.split('/').last, folder + '/' + filename) + zipfile.add(File.basename(filename), folder + '/' + filename) end zipfile.get_output_stream("ReadMe"){ |os| os.write "Homeworks"