如何压缩和解压缩文件 [英] How to compress and decompress file

查看:103
本文介绍了如何压缩和解压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从文件上传控件压缩文件并复制到FTP服务器,并从FTP服务器解压缩该文件,并在浏览器中显示为PDF。有什么解决方案吗?我在谷歌尝试了很多,但所有结果显示在本地机器中保存文件。



我尝试过:



i在谷歌尝试了很多,但所有结果显示在本地机器中保存文件。

I want to Compress the File from File Upload Control and Copy to FTP server and also Decompress that file From FTP server and show as PDF in the browser.Is there any solution for this? i tried lot in google, but all results shows to save file in the Local Machine.

What I have tried:

i tried lot in google, but all results shows to save file in the Local Machine.

推荐答案

你要去需要一个javascript组件,如JSZip,在客户端代码可以将文件上传到FTP服务器之前压缩客户端上的文件。



一旦有,我可能有一个运行的服务,检查ZIP文件的上传文件夹。在那里,此服务必须将文件移动到前期文件夹,将内容解压缩到目标登台文件夹,验证内容是否适用于好的内容,将其移动到适当的生产文件夹并清除分段和预览 - 暂存文件夹,然后通知网站内容已准备就绪。



但这只是我。



您可以完全跳过FTP服务器,只需将压缩文件直接上传到Web服务器并同步执行上述所有步骤并返回解压缩的PDF或一些错误但如果文件足够大,客户端可能会在您之前超时将响应的第一个字节发送回客户端。
You're going to need a javascript component, like JSZip, to compress the file on the client side before your client-side code can upload the file to the FTP server.

Once there, I'd probably have a service running that checks that upload folder for ZIP files. Once there, this service would have to move the file to a pre-stage folder, unzip the content to a target staging folder, verify the content for good content if applicable, move it to an appropriate production folder and clear out the staging and pre-staging folders, then notify the web site that the content is ready.

But that's just me.

You could skip the FTP server entirely and just upload the zipped file directly to the web server and do all the steps above synchronously and return the unzipped PDF or some error but if the file is big enough the client may just time out before you send the first byte of your response back to the client.


这篇关于如何压缩和解压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆