即时创建 zip 或 tar?
我可能不会为此烦恼,但如果它非常简单,我可能会考虑它。我正在设计的网站可以容纳数十万个文件。我不知道我们是只下载一次还是多次下载。现在的选择是 A) 只是文件 B) 包含文件 + 许可证和条件的存档。
我试图弄清楚提供两者并使用诸如 file.open/read 之类的东西在包含许可证和其他 zip 内容的存档头之前和之后添加前缀是有效的。我最大的担忧是打开/读取文件的效率不如让服务器传输文件那么有效,并且如果很难动态生成和更改 zip 的内容(如果用户希望更改许可证或者我们想添加其他数据,例如作者描述、作者 URL 和网站上的永久链接)
是否有效?我如何仅动态创建文件(仅使用原始文件和从数据库中提取的数据)?
PS:我使用 debian/apache/asp.net 使用 xsp.net 和 mono。
I may NOT bother with this but if its very simple i may consider it. The site i am working on by design is to hold hundreds of thousands of files. I dont know if we'll have only one download or multiple. Right now the choices are A) Just the file B) An archive that has the file + license and conditions.
I am trying to figure out it can be efficient to offer both and use something like file.open/read prefixing an archive header before it and after it which contains the license and other zip contents. My biggest worries are doing file open/read will not be as efficient as letting the server transmit the file and if its hard to generate and change the contents of the zip dynamically (if a user wishes to change the license or if we want to add other data such as author description, author URL and a permalink on the site)
Is it efficient and how would i create the file dynamically only the original file and data pulled from the database?
PS: I am using debian/apache/asp.net using xsp.net and mono.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SharpZipLib 是一个非常好的基于流的库,您可以使用它来创建存档文件。
SharpZipLib is a very nice stream based library that you can use to create archive files.
您可以使用 zip 库 (System.IO.Packaging.ZipPackage 、dotnetzip、SharpZipLib) 或用于压缩文件的事件命令行程序(例如 7zip)
。该库应该提供更好的性能。
然而,重要的是添加一个缓存层,即 zip 文件应该缓存在文件系统中,以便在请求相同时可以直接提供它们。
You can use zip libraries (System.IO.Packaging.ZipPackage, dotnetzip, SharpZipLib) or event command line programs (say 7zip) for compressing the file
. The library should offer better performance.
However, important thing will be to add an caching layer i.e. zip files should be cached in file system so that they can be served directly if request comes for the same.