How to unzip a file in Ruby on Rails?

后端 未结 4 1686
盖世英雄少女心
盖世英雄少女心 2020-12-08 06:37

I\'m uploading a file to the server in Ruby on Rails

Normally, it\'s a text file and I save it in the model as a \'file\' field in a Submission ActiveRecord with oth

4条回答
  •  不思量自难忘°
    2020-12-08 07:00

    From the RubyZip project page:

    Rubyzip interface changed!!! No need to do require "zip/zip" and Zip prefix in class names removed.

    So, the example code from @ben-lee should be updated to something like this:

    require 'zip'
    
    Zip::File.open("my.zip") do |zipfile|
      zipfile.each do |file|
        # do something with file
      end
    end
    

提交回复
热议问题