Opening a ZIP file multipart / form-data with rubyzip

I want to extract files to a zip file that I downloaded into my Rails application. Files in the ZIP archive will be stored in the database.

I want to open a ZIP file in my action without first saving the file in a folder - I want to open the multipart / form-data stream with rubyzip.

It looks like rubyzip ZipFile.open accepts only the file name - not the input / output stream.

What I need to change in rubyzip so that I can open the zip file as a stream, for example:

Zip::ZipFile.open(params["zip_file"]) do |zip_file|
 ...
end

Thanks. Jörg

+3
source share
2 answers

Using

Zip::ZipFile.open(params["zip_file"].path) do |zip_file|
 ...
end

must work.

+4
source

I will give you some advice that you did not ask for.

, , Rails, HTTP-, , . , ( , ?), .

  • .
+4

Source: https://habr.com/ru/post/1709784/


All Articles