24

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?

guy
  • 251
  • 2
  • 5

3 Answers3

8

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+.

hynekcer
  • 14,942
  • 6
  • 61
  • 99
Hirvesh
  • 7,636
  • 15
  • 59
  • 72
3

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.

japrescott
  • 4,736
  • 3
  • 25
  • 37
  • It's possible to "resume" an upload if the user selects the same file again, but you're right that you cannot access a file that a user selected in a previous session (i.e., you can't just access the file by path, the user would have to select the file in a `` or via drag+drop) – cwa Oct 16 '17 at 20:50
0

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.

tommy chheng
  • 9,108
  • 9
  • 55
  • 72