1

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?

goo
  • 2,230
  • 4
  • 32
  • 53

1 Answers1

4

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
Ajay Barot
  • 1,681
  • 1
  • 21
  • 37
CamilleLDN
  • 850
  • 6
  • 11