17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/zipload.rb', line 17
def self.download_file(url)
puts 'Downloading zipped file from url: ' + url
fileNamePath = file_name_with_extension_from_url(url)
uri = URI(url)
zipped_folder = Net::HTTP.get(uri)
File.open(fileNamePath, 'wb') do |file|
file.write(zipped_folder)
end
Zip::File.open(fileNamePath) { |zip_file|
zip_file.each { |file|
file_path=File.join('output', file.name)
FileUtils.mkdir_p(File.dirname(file_path))
zip_file.(file, file_path) unless File.exist?(file_path)
}
}
end
|