From 24ce5191c324e021f5913b7d9efa5933fbbb0db0 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 27 Apr 2015 12:04:08 +0800 Subject: [PATCH] =?UTF-8?q?zip=E6=89=93=E5=8C=85=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=9C=89=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index df354f107..1d03ef629 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -180,6 +180,7 @@ class ZipdownController < ApplicationController def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) + ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" zipfile_name = "#{output_path}/#{rename_zipfile}" @@ -189,7 +190,7 @@ class ZipdownController < ApplicationController rename_file = File.basename(filename) rename_file = filename_to_real( File.basename(filename)) if is_attachment begin - zipfile.add(rename_file, filename) + zipfile.add(ic.iconv(rename_file), filename) rescue Exception => e zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write l(:label_file_exist)} next @@ -238,4 +239,4 @@ class ZipdownController < ApplicationController attach = Attachment.find_by_disk_filename(name) attach.filename end -end \ No newline at end of file +end