2014-07-16 2 views
1

rubyzip을 사용하여 파일을 압축하는 방법을 찾으려고합니다. 새 버전이 작동하지 않아 버전 0.9.9로 롤백되었습니다. 아래 내가 비록 오류가권한이 거부되었습니다.

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합니다. 디스크 사용 권한과 관련이있는 것 같군요. 내가 어떻게 고칠 수 있니? 당신이 거기에 쓸 수있는 권한이 없기 때문에

답변

3

는, 루트 파일 시스템에 아카이브 파일을 넣어하지 마십시오 :

- zipfile_name = "/archive.zip" 
+ zipfile_name = "/temp/archive.zip" 

는 도움이되기를 바랍니다.

관련 문제