0
def extract_zip(file, destination)
FileUtils.mkdir_p(destination)

Zip::ZipFile.open(file) do |zip_file|
  zip_file.each do |f|
     file_path = File.join(destination, f.name)
     zip_file.extract(entry, file_path) unless File.exist?(file_path)
   end
 end
end

I get the error undefined method `name' for nil:NilClass for this line

file_path = File.join(destination, f.name)

the zip file is not opening, idk why

msc
  • 67
  • 8
  • Worked for me. I would double check that your zip file is correct. Also where you have "entry" it should be "f". And you seem to be using an old version of rubyzip. Maybe try upgrading? Latest version is 1.2.1. – SpyMachine Dec 03 '17 at 13:06
  • i get the error that the zip file gets corrupted after i download it – msc Dec 03 '17 at 20:45

0 Answers0