diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 12fead4f2..71c445dc4 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -24,7 +24,7 @@ class TestController < ApplicationController end @paths = homeworks_attach_path zipfile = ziping homeworks_attach_path - send_file zipfile, :filename => bid.name, + send_file zipfile, :filename => filename_for_content_disposition(bid.name), :type => detect_content_type(zipfile) rescue Errno::ENOENT => e logger.error "[Errno::ENOENT] ===> #{e}" diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 7eb06d270..53b40942a 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -11,7 +11,7 @@ class ZipdownController < ApplicationController def download if User.current.logged? begin - send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => params[:filename], :type => detect_content_type(params[:file]) + send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file]) rescue => e render file: 'public/no_file_found.html' end @@ -59,9 +59,10 @@ class ZipdownController < ApplicationController if homework != nil unless homework.attachments.empty? zipfile = zip_homework_by_user homework - send_file zipfile.file_path, :filename => ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) + - "_" + homework.user.show_name + - "_" + homework.name + ".zip", :type => detect_content_type(zipfile.file_path) if(zipfile) + filename = ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) + + "_" + homework.user.show_name + + "_" + homework.name + ".zip" + send_file zipfile.file_path, :filename => filename_for_content_disposition(filename), :type => detect_content_type(zipfile.file_path) if(zipfile) else render file: 'public/no_file_found.html' end