使用 ZipOutputStream 的 Zip 文件中的子目录
我正在使用此处描述的技术创建一个 zip 文件:
http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/
客户已询问我在此 zip 文件中包含子目录。我搜索了 ZipOutputStream 文档,但我看不到包含目录的方法。有没有办法用 ZipOutputStream 做到这一点?我应该使用与 ZipOutputStream 不同的类吗?
此外,我正在压缩的文件不在本地文件系统上,而是存储在云服务中。
I am creating a zip file using the technique described here:
http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/
The client has asked that I include subdirectories in this zip file. I have searched the ZipOutputStream documentation but I see no way to include directories. Is there a way I can do this with ZipOutputStream? Should I be using a different class than ZipOutputStream?
Also, the files that I am zipping are not on the local filesystem, but are stored in a cloud service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了答案,我想我会把它放在这里以便搜索引擎找到。
不管怎样,我发布的链接
用于将文件添加到 zip 文件中。事实证明,该字符串参数不仅仅是一个文件名,它也可以是一个路径!因此,使用
Will 会使您的 zip 文件包含一个名为“some-random-folder”的文件夹,以及一个名为“some-funny-name.jpg”的文件。
Figured out the answer, thought I would put it here for search engines to find.
Anyway, the link I posted used
to add files to the zip file. Turns out, that string parameter isn't just a filename, it can be a path as well! So using
Will make your zip file contain a folder called 'some-random-folder', with a file called 'some-funny-name.jpg'.