Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resume a broken upload in 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?

like image 737
guy Avatar asked Oct 09 '11 13:10

guy


People also ask

What is a resumable upload?

A resumable upload allows you to resume data transfer operations to Cloud Storage after a communication failure has interrupted the flow of data. Resumable uploads work by sending multiple requests, each of which contains a portion of the object you're uploading.

How do I enable file upload in HTML?

The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the multiple attribute. Tip: Always add the <label> tag for best accessibility practices!


2 Answers

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

like image 74
Hirvesh Avatar answered Oct 11 '22 04:10

Hirvesh


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.

like image 35
japrescott Avatar answered Oct 11 '22 06:10

japrescott