Ruby:读取临时zip文件
发布时间:2020-12-17 03:15:04 所属栏目:百科 来源:网络整理
导读:我有一个zip文件的TempFile对象,我想从中读取如下: Zip::ZipFile.open_buffer(tempfile) do |zipfile| ...end 但是,当我这样做时,我收到以下错误: Zip::ZipFile.open_buffer expects an argument of class String or IO. Found: Tempfile 我也试过了 Zip::
我有一个zip文件的TempFile对象,我想从中读取如下:
Zip::ZipFile.open_buffer(tempfile) do |zipfile| ... end 但是,当我这样做时,我收到以下错误: Zip::ZipFile.open_buffer expects an argument of class String or IO. Found: Tempfile 我也试过了 Zip::ZipFile.open(tempfile.path) do |zipfile| ... end 但那会回来 can't dup NilClass 如何处理临时zip文件? 解决方法
请参阅以下文章
http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/,该文章解释了如果使用Tempfile,如何使用更基本的接口Zip :: ZipOutputStream
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |