Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
9cb31d75de
|
@ -180,14 +180,17 @@ class ZipdownController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[])
|
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"
|
rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip"
|
||||||
zipfile_name = "#{output_path}/#{rename_zipfile}"
|
zipfile_name = "#{output_path}/#{rename_zipfile}"
|
||||||
|
|
||||||
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
|
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
|
||||||
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
||||||
files_paths.each do |filename|
|
files_paths.each do |filename|
|
||||||
rename_file = File.basename(filename)
|
rename_file = ic.iconv( (File.basename(filename)) ).to_s
|
||||||
rename_file = filename_to_real( File.basename(filename)) if is_attachment
|
rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment
|
||||||
|
|
||||||
begin
|
begin
|
||||||
zipfile.add(rename_file, filename)
|
zipfile.add(rename_file, filename)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
|
Loading…
Reference in New Issue