How do I get a zipped file's content using the rubyzip library?

孤者浪人 提交于 2019-12-05 06:58:19

Found an even more simple way:

asset.data = entry.get_input_stream.read

It would seem that you can either use the read_local_entry method like this:

asset.data = entry.read_local_entry {|z| z.read }

Or, you could save the entry with this method:

data = entry.extract "#{RAILS_ROOT}/#{entry.name}"
asset.data = File.read("#{RAILS_ROOT}/#{entry.name}")

I'm not sure how those will work, but maybe they'll help you find the right method (if this ain't it).

And, one more alternative:

asset.data = zipfile.file.read(entry.name)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!