I have this action in my photos_controller
def open_my_zip
url = "http://www.vbaccelerator.com/home/VB/Code/vbMedia/Audio/Lossless_WAV_Compression/Sample_APE_File.zip"
Zip::File.open(url) do |zipfile|
zipfile.each do |file|
# do something with file
Rails.logger.debug "hi"
end
end
end
For some reason, I'm getting this error
Zip::ZipError (File http://www.vbaccelerator.com/home/VB/Code/vbMedia/Audio/Lossless_WAV_Compression/Sample_APE_File.zip not found):
But the zip file DOES exist... What am I doing wrong here?
You cannot use the URL directly like that. Try the following code:
require 'open-uri'
url = "http://www.vbaccelerator.com/home/VB/Code/vbMedia/Audio/Lossless_WAV_Compression/Sample_APE_File.zip"
zipfilename = open(url)
Zip::ZipFile.open(zipfilename) do |zipfile|
end