动态生成图像 zip 时出现 ruby​​zip 错误:未找到中央目录结尾签名

发布于 2024-10-25 22:31:12 字数 429 浏览 9 评论 0原文

我正在从图像集合生成一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤凫 2024-11-01 22:31:12

知道了!

这是因为 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文