小编Hél*_*nda的帖子

为什么二进制文件在压缩时会损坏?

我有一项通过网络提供压缩文件的服务。该 zip 包含 Windows 平台的可执行文件。

我正在使用 RubyZip 库来压缩文件,但该过程会损坏二进制文件。在我的本地服务器上,我们通过系统调用使用 zip 命令,它工作正常。

zip 命令在 Heroku 上不可用,我根本没有选择。

我正在使用这个类:

require 'zip/zip'

# This is a simple example which uses rubyzip to
# recursively generate a zip file from the contents of
# a specified directory. The directory itself is not
# included in the archive, rather just its contents.
#
# Usage:
#   directoryToZip = "/tmp/input"
#   outputFile = "/tmp/out.zip"   
#   zf = ZipFileGenerator.new(directoryToZip, outputFile)
#   zf.write()
class ZipFileGenerator

  # Initialize with the directory …
Run Code Online (Sandbox Code Playgroud)

ruby windows zip heroku binary-data

4
推荐指数
1
解决办法
3121
查看次数

标签 统计

binary-data ×1

heroku ×1

ruby ×1

windows ×1

zip ×1