动态生成图像 zip 时出现 rubyzip 错误:未找到中央目录结尾签名
我正在从图像集合生成一个 zip 文件,然后将其发送给用户。
我使用的代码与本页给出的示例几乎完全相同;
http: //info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/
它在我的本地开发盒上工作得很好,但是当我在临时服务器上运行它,得到一个零长度的 zip 文件,当我尝试打开它时出现以下错误。
“未找到中央目录结尾签名”
显然,当它在我的开发机器上运行良好时,很难解决我出错的地方!
干杯, 格雷姆
I'm generating a zip file from a collection of images which is then sent to the user.
I'm using code which is almost exactly the same as the example given on this page;
http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/
It works absolutely fine on my local development box, but when I run it on my staging server, I get a zero length zipfile which has the following error when I try to open it.
'End-of-central-directory signature not found'
Obviously it's hard to troubleshoot where I'm going wrong when it works fine on my development machine!
Cheers,
Graeme
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
知道了!
这是因为 Rails 3 默认使用 x_sendfile,而服务器没有为此设置。
最终与 zip 无关,这只是文件发送。这篇文章解释了一切;
Rails 使用 send_file 发送 0 字节文件
Got it!
It's because Rails 3 defaults to using x_sendfile, which the server isn't setup for.
Nothing to do with zips at all in the end, it's simply file sending. This post explains everything;
Rails sends 0 byte files using send_file