1
我试图找出一种使用rubyzip压缩文件的方法。我回到了0.9.9版本,因为新版本不起作用。下面是我想用权限在使用rubyzip时被拒绝
require 'rubygems'
require 'zip/zip'
folder = "/temp"
input_filenames = ['COKE.csv', 'GM.csv', 'GOOG.csv']
zipfile_name = "/archive.zip"
Zip::ZipFile.open(zipfile_name, Zip::ZipFile::CREATE) do |zipfile|
input_filenames.each do |filename|
# Two arguments:
# - The name of the file as it will appear in the archive
# - The original file, including the path to find it
zipfile.add("archive", folder + '/' + filename)
end
zipfile.get_output_stream("myFile") { |os| os.write "myFile contains just this" }
end
我得到一个错误,虽然,以测试它的代码,则errno :: EACCES:权限被拒绝 - /archive.zip20140716-17537-1t9f1pd。我想这与光盘权限有关?我该如何解决它?