有什么方法可以使用 Perl CGI 脚本恢复失败的上传吗?
该应用程序很简单,是一个发布到 Perl 脚本的 HTML 表单。问题是我们有时会让客户上传非常大的文件(> 500mb),而他们的互联网连接有时可能不可靠。
有没有办法像 WinSCP 一样恢复失败的传输,或者如果客户端不支持它就无法完成?
The application is simple, an HTML form that posts to a Perl script. The problem is we sometimes have our customers upload very large files (gt 500mb) and their internet connections can be unreliable at times.
Is there any way to resume a failed transfer like in WinSCP or is this something that can't be done without support for it in the client?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AFAIK,它必须得到客户端的支持。基本上,客户端和服务器需要协商文件的哪些部分(可能定义为“multipart/form-data”POST 中的部分)已经上传,然后服务器代码需要能够将新上传的数据与现有的一个。
最好的解决方案是使用自定义上传器代码,通常用 Java 实现,尽管我认为这在 Flash 中也可能实现。您甚至可以通过 JavaScript 来完成此操作 - 请参阅下面的 2 个部分和示例
以下是 Google 如何使用 YouTube 实现此目的的示例:http://code.google.com/apis/youtube/2.0/developers_guide_protocol_resumable_uploads.html
它使用“308 Resume Incomplete”HTTP 响应,发送
range: bytes =0-408
来自服务器的标头,用于指示已上传的内容。有关该主题的其他想法:
http://code.google.com/ p/gears/wiki/ResumableHttpRequestsProposal
有人在客户端使用 Google Gears 并在服务器端使用 PHP 实现了这一点(后者可以轻松移植到 Perl)
http://michaelshadle。 com/2008/11/26/updates-on-the-http-file-upload-front/
http: //michaelshadle.com/2008/12/03/updates-on-the-http-file-upload-front-part-2/
AFAIK, it must be supported by the client. Basically, the client and the server need to negotiate which parts of the file (likely defined as parts in "multipart/form-data" POST) have already been uploaded, and then the server code needs to be able to merge newly uploaded data with existing one.
The best solution is to have custom uploader code, usually implemented in Java though I think this may be possible in Flash as well. You might be even able to do this via JavaScript - see 2 sections with examples below
Here's an example of how Google did it with YouTube: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_resumable_uploads.html
It uses "308 Resume Incomplete" HTTP response which sends
range: bytes=0-408
header from the server to indicate what was already uploaded.For additional ideas on the topic:
http://code.google.com/p/gears/wiki/ResumableHttpRequestsProposal
Someone implemented this using Google Gears on calient side and PHP on server side (the latter you can easily port to Perl)
http://michaelshadle.com/2008/11/26/updates-on-the-http-file-upload-front/
http://michaelshadle.com/2008/12/03/updates-on-the-http-file-upload-front-part-2/
遗憾的是您的客户端无法使用 ftp 上传,因为这已经包含了类似的功能。 HTTP 中还有“分块传输编码”。我不知道哪些 Perl 模块可能已经支持它。
It's a shame that your clients can't use ftp uploading, since this already includes abilities like that. There is also "chunked transfer encoding" in HTTP. I don't know what Perl modules might support it already.