문자열에 zip 아카이브가 있지만 rubyzip gem이 파일의 입력을 원하는 것처럼 보입니다. 내가 가지고 올 것 중에 최고는 Zip::ZipFile.foreach()
에 파일 이름을 전달하는 목적을위한 임시 파일을 압축 아카이브를 작성하는 것입니다, 그러나 이것은 고문 보인다 :문자열에서 zip 아카이브 압축 해제
require 'zip/zip'
def unzip(page)
"".tap do |str|
Tempfile.open("unzip") do |tmpfile|
tmpfile.write(page)
Zip::ZipFile.foreach(tmpfile.path()) do |zip_entry|
zip_entry.get_input_stream {|io| str << io.read}
end
end
end
end
간단한 방법이 있나요?
참고 : Ruby Unzip String도 참조하십시오.
감사합니다. http://stackoverflow.com/a/14912237/558639에있는 전체 답변보기 –