Rails:“找不到Zip :: ZipError文件”?

时间:2013-09-20 15:09:49

标签: ruby-on-rails rubyzip

我在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

出于某种原因,我收到了此错误

Zip::ZipError (File http://www.vbaccelerator.com/home/VB/Code/vbMedia/Audio/Lossless_WAV_Compression/Sample_APE_File.zip not found):

但是zip文件存在......我在这里做错了什么?

1 个答案:

答案 0 :(得分:2)

您无法直接使用此网址。请尝试以下代码:

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