修改打包下载文件名为创建该作业的学生姓名_学生学号
This commit is contained in:
parent
ecd5a7b2fb
commit
1c50646677
|
@ -72,7 +72,7 @@ class ZipdownController < ApplicationController
|
|||
homeattach.attachments.each do |attach|
|
||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||
end
|
||||
zipping("#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
||||
zipping("#{homeattach.user.name}_#{homeattach.user.user_extensions.student_id}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
||||
end
|
||||
|
||||
|
||||
|
@ -81,14 +81,14 @@ class ZipdownController < ApplicationController
|
|||
ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE')
|
||||
input_filename = files_paths
|
||||
|
||||
rename_zipfile = zip_name_refer ||= "archive_#{Time.now.to_i}.zip"
|
||||
rename_zipfile = zip_name_refer ||= "homework.zip"
|
||||
zipfile_name = "#{output_path}/#{rename_zipfile}"
|
||||
|
||||
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
|
||||
|
||||
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
||||
input_filename.each do |filename|
|
||||
rename_file = Time.now.to_i.to_s+ ic.iconv( (File.basename(filename)) ).to_s
|
||||
rename_file = ic.iconv( (File.basename(filename)) ).to_s
|
||||
rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment
|
||||
|
||||
zipfile.add(rename_file, filename)
|
||||
|
|
Loading…
Reference in New Issue