如何在 HTML5 中恢复损坏的上传

发布于 2024-12-08 19:04:03 字数 239 浏览 4 评论 0原文

我正在尝试向 html5 文件上传器添加简历功能。

我需要能够在浏览器关闭(并重新打开)并且丢失文件对象后恢复,我不希望用户再次拖动/打开文件。

到目前为止,我使用java applet 来做到这一点,但我希望找到一个html5 解决方案来解决这个问题。

我考虑过将文件保存在本地存储中,但它们太大了。

有没有办法只保存文件对象的路径或任何其他可以帮助我重新打开文件的信息,而不要求用户重新打开文件?

I am trying to add resume functionality to html5 file uploader.

I need to be able to resume after browser was closed (and reopened) and I lost the file object, I do not want the user to drag/open the file again.

Until now I used java applet to do it but I was hoping to find an html5 solution for this problem.

I thought about saving the files in local storage but they are too big.

Is there a way to save only the file object the path or any other information that might help me reopen the file without asking the user to reopen the file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三生殊途 2024-12-15 19:04:03

您可能想尝试 Resumable.js - 通过 HTML5 文件提供多个同时、稳定和可恢复上传的 JavaScript 库API(或其域www.resumablejs.com)。

可恢复。 Node.js 是一个 JavaScript 库,通过 HTML5 文件 API 提供多个同时、稳定和可恢复的上传。

该库旨在通过 HTTP 上传大文件时引入容错功能。这是通过将每个文件分割成小块来完成的;每当块上传失败时,就会重试上传,直到过程完成。这允许上传在本地或服务器的网络连接丢失后自动恢复上传。此外,它允许用户暂停和恢复上传而不会丢失状态。

Resumable.js 依赖于 HTML5 文件 API 以及将文件分成更小的部分的能力。目前,这意味着支持仅限于 Firefox 4+ 和 Chrome 11+。

You might want to try out Resumable.js - JavaScript Library Providing Multiple Simultaneous, Stable And Resumable Uploads Via The HTML5 File API (or its domain www.resumablejs.com).

Resumable. js a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API.

The library is designed to introduce fault-tolerance into the upload of large files through HTTP. This is done by splitting each files into small chunks; whenever the upload of a chunk fails, uploading is retried until the procedure completes. This allows uploads to automatically resume uploading after a network connection is lost either locally or to the server. Additionally, it allows for users to pause and resume uploads without loosing state.

Resumable.js relies on the HTML5 File API and the ability to chunks files into smaller pieces. Currently, this means that support is limited to Firefox 4+ and Chrome 11+.

北方的韩爷 2024-12-15 19:04:03

抱歉,这是不可能的。您可以使用 javascript 访问的文件和浏览器之间的链接(FileURL)会在关闭窗口后(当然,在关闭浏览器时)被破坏。您可以保存文件的名称和上传的数量/部分,并请求用户再次上传该文件,从上次中断的地方继续,但未经用户同意不会自动上传。

/编辑:为什么投反对票?请留下评论,让我知道我说错了什么!问题是当用户关闭浏览器时如何恢复上传。那是不可能的。当浏览器保持打开且连接丢失时可以停止/恢复上传,但当用户关闭浏览器时则不能停止/恢复上传(引用丢失)。但是,您可以将文件复制到临时文件系统,然后从那里恢复上传但这需要用户同意,并且仅限于用户提供给您使用的空间量。

sorry, it is not possible. The link between the file and the browser, that you can access with javascript (the FileURL) is destroyed after closing the window (and for sure, when closing the browser). You could save the name of the file and the amounts/parts uploaded and request the user to upload that file again, continuing from where he left off, but not automatically, without the users consent.

/Edit: Why the negative votes? Please leave a comment so I know what I said wrong! The question is about how to resume an upload when the user closes the browser. And that isn't possible. It is possible to stop/resume an upload while the Browser remains open and connection is lost, but not when the user closes the browser (references are lost). You could however copy the file to a temporary filesystem and then resume upload from there but that needs user consent and its limited to the amount of space the user provisions you to use.

橘虞初梦 2024-12-15 19:04:03

这对于较新的浏览器(Chrome、Firefox)是可能的。

YouTube 上传器就是一个很好的例子。
http://support.google.com/youtube/bin/static.py?hl=zh-CN&topic=1719827&guide=1719823&page=guide.cs&answer=1672758

< a href="http://www.youtube.com/watch?v=L5ebSn9HgJ4" rel="nofollow">http://www.youtube.com/watch?v=L5ebSn9HgJ4

我不完全确定他们的实现是如何完全工作的,但这是可能的。

This is possible with newer browsers(Chrome, Firefox).

The youtube uploader is a good example.
http://support.google.com/youtube/bin/static.py?hl=en&topic=1719827&guide=1719823&page=guide.cs&answer=1672758

http://www.youtube.com/watch?v=L5ebSn9HgJ4

I'm not entirely sure how their implementation fully works, but it is possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文