From 9957cfd40164c0a92857542d42b5095e1d9f65dc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 10 Dec 2014 17:04:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=A6=E7=94=9F=E6=97=A0?= =?UTF-8?q?=E5=AD=A6=E5=8F=B7=E6=97=B6=E6=89=93=E5=8C=85=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=85=B6=E4=B8=8A=E4=BC=A0=E4=BD=9C=E4=B8=9A=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index f0dc157b5..d4699b6c4 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -44,7 +44,9 @@ class ZipdownController < ApplicationController if homework != nil unless homework.attachments.empty? zipfile = zip_homework_by_user homework - send_file zipfile, :filename => homework.user.user_extensions.student_id + "_" + homework.user.lastname + homework.user.firstname + "_" + homework.name+".zip", :type => detect_content_type(zipfile) if(zipfile) + send_file zipfile, :filename => (homework.user.user_extensions.student_id.nil? ? "" : homework.user.user_extensions.student_id) + + "_" + (homework.user.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) + + "_" + homework.name + ".zip", :type => detect_content_type(zipfile) if(zipfile) else render file: 'public/no_file_found.html' end @@ -78,7 +80,7 @@ class ZipdownController < ApplicationController homeattach.attachments.each do |attach| homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{homeattach.user.user_extensions.student_id}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{(homework.user.user_extensions.student_id.nil? ? "" : homework.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) end