You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resumable.js is a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API.
4
+
Flow.js is a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API.
8
5
9
6
The library is designed to introduce fault-tolerance into the upload of large files through HTTP. This is done by splitting each file into small chunks. Then, 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, resume and even recover uploads without losing state because only the currently uploading chunks will be aborted, not the entire upload.
10
7
11
-
Resumable.js does not have any external dependencies other than the `HTML5 File API`. This is relied on for the ability to chunk files into smaller pieces. Currently, this means that support is limited to Firefox 4+, Chrome 11+, Safari 6+ and Internet Explorer 10+.
8
+
Flow.js does not have any external dependencies other than the `HTML5 File API`. This is relied on for the ability to chunk files into smaller pieces. Currently, this means that support is limited to Firefox 4+, Chrome 11+, Safari 6+ and Internet Explorer 10+.
12
9
13
10
Samples and examples are available in the `samples/` folder. Please push your own as Markdown to help document the project.
After this, interaction with Resumable.js is done by listening to events:
43
+
After this, interaction with Flow.js is done by listening to events:
47
44
48
45
r.on('fileAdded', function(file, event){
49
46
...
@@ -57,19 +54,19 @@ After this, interaction with Resumable.js is done by listening to events:
57
54
58
55
## How do I set it up with my server?
59
56
60
-
Most of the magic for Resumable.js happens in the user's browser, but files still need to be reassembled from chunks on the server side. This should be a fairly simple task and can be achieved in any web framework or language, which is able to receive file uploads.
57
+
Most of the magic for Flow.js happens in the user's browser, but files still need to be reassembled from chunks on the server side. This should be a fairly simple task and can be achieved in any web framework or language, which is able to receive file uploads.
61
58
62
59
To handle the state of upload chunks, a number of extra parameters are sent along with all requests:
63
60
64
-
*`resumableChunkNumber`: The index of the chunk in the current upload. First chunk is `1` (no base-0 counting here).
65
-
*`resumableTotalChunks`: The total number of chunks.
66
-
*`resumableChunkSize`: The general chunk size. Using this value and `resumableTotalSize` you can calculate the total number of chunks. Please note that the size of the data received in the HTTP might be lower than `resumableChunkSize` of this for the last chunk for a file.
67
-
*`resumableTotalSize`: The total file size.
68
-
*`resumableIdentifier`: A unique identifier for the file contained in the request.
69
-
*`resumableFilename`: The original file name (since a bug in Firefox results in the file name not being transmitted in chunk multipart posts).
70
-
*`resumableRelativePath`: The file's relative path when selecting a directory (defaults to file name in all browsers except Chrome).
61
+
*`flowChunkNumber`: The index of the chunk in the current upload. First chunk is `1` (no base-0 counting here).
62
+
*`flowTotalChunks`: The total number of chunks.
63
+
*`flowChunkSize`: The general chunk size. Using this value and `flowTotalSize` you can calculate the total number of chunks. Please note that the size of the data received in the HTTP might be lower than `flowChunkSize` of this for the last chunk for a file.
64
+
*`flowTotalSize`: The total file size.
65
+
*`flowIdentifier`: A unique identifier for the file contained in the request.
66
+
*`flowFilename`: The original file name (since a bug in Firefox results in the file name not being transmitted in chunk multipart posts).
67
+
*`flowRelativePath`: The file's relative path when selecting a directory (defaults to file name in all browsers except Chrome).
71
68
72
-
You should allow for the same chunk to be uploaded more than once; this isn't standard behaviour, but on an unstable network environment it could happen, and this case is exactly what Resumable.js is designed for.
69
+
You should allow for the same chunk to be uploaded more than once; this isn't standard behaviour, but on an unstable network environment it could happen, and this case is exactly what Flow.js is designed for.
73
70
74
71
For every request, you can confirm reception in HTTP status codes (can be change through the `permanentErrors` option):
75
72
@@ -79,7 +76,7 @@ For every request, you can confirm reception in HTTP status codes (can be change
79
76
80
77
## Handling GET (or `test()` requests)
81
78
82
-
Enabling the `testChunks` option will allow uploads to be resumed after browser restarts and even across browsers (in theory you could even run the same file upload across multiple tabs or different browsers). The `POST` data requests listed are required to use Resumable.js to receive data, but you can extend support by implementing a corresponding `GET` request with the same parameters:
79
+
Enabling the `testChunks` option will allow uploads to be resumed after browser restarts and even across browsers (in theory you could even run the same file upload across multiple tabs or different browsers). The `POST` data requests listed are required to use Flow.js to receive data, but you can extend support by implementing a corresponding `GET` request with the same parameters:
83
80
84
81
* If this request returns a `200` HTTP code, the chunks is assumed to have been completed.
85
82
* If the request returns anything else, the chunk will be uploaded in the standard fashion.
@@ -88,12 +85,12 @@ After this is done and `testChunks` enabled, an upload can quickly catch up even
88
85
89
86
## Full documentation
90
87
91
-
### Resumable
88
+
### Flow
92
89
#### Configuration
93
90
94
91
The object is loaded with a configuration options:
95
92
96
-
var r = new Resumable({opt1:'val', ...});
93
+
var r = new Flow({opt1:'val', ...});
97
94
98
95
Available configuration options are:
99
96
@@ -103,7 +100,7 @@ Available configuration options are:
103
100
*`forceChunkSize` Force all chunks to be less or equal than chunkSize. Otherwise, the last chunk will be greater than or equal to `chunkSize`. (Default: `false`)
104
101
*`simultaneousUploads` Number of simultaneous uploads (Default: `3`)
105
102
*`fileParameterName` The name of the multipart POST parameter to use for the file chunk (Default: `file`)
106
-
*`query` Extra parameters to include in the multipart POST with data. This can be an object or a function. If a function, it will be passed a ResumableFile and a ResumableChunk object (Default: `{}`)
103
+
*`query` Extra parameters to include in the multipart POST with data. This can be an object or a function. If a function, it will be passed a FlowFile and a FlowChunk object (Default: `{}`)
107
104
*`headers` Extra headers to include in the multipart POST with data (Default: `{}`)
108
105
*`withCredentials` Standard CORS requests do not send or set any cookies by default. In order to
109
106
include cookies as part of the request, you need to set the `withCredentials` property to true.
@@ -125,25 +122,25 @@ parameter must be adjusted together with `progressCallbacksInterval` parameter.
125
122
126
123
#### Properties
127
124
128
-
*`.support` A boolean value indicator whether or not Resumable.js is supported by the current browser.
129
-
*`.opts` A hash object of the configuration of the Resumable.js instance.
130
-
*`.files` An array of `ResumableFile` file objects added by the user (see full docs for this object type below).
125
+
*`.support` A boolean value indicator whether or not Flow.js is supported by the current browser.
126
+
*`.opts` A hash object of the configuration of the Flow.js instance.
127
+
*`.files` An array of `FlowFile` file objects added by the user (see full docs for this object type below).
131
128
132
129
#### Methods
133
130
134
131
*`.assignBrowse(domNodes, isDirectory, singleFile)` Assign a browse action to one or more DOM nodes. Pass in `true` to allow directories to be selected (Chrome only). To prevent multiple file uploads
135
132
set singleFile to true.
136
133
*`.assignDrop(domNodes)` Assign one or more DOM nodes as a drop target.
137
-
*`.on(event, callback)` Listen for event from Resumable.js (see below)
134
+
*`.on(event, callback)` Listen for event from Flow.js (see below)
138
135
*`.upload()` Start or resume uploading.
139
136
*`.pause()` Pause uploading.
140
137
*`.resume()` Resume uploading.
141
-
*`.cancel()` Cancel upload of all `ResumableFile` objects and remove them from the list.
138
+
*`.cancel()` Cancel upload of all `FlowFile` objects and remove them from the list.
142
139
*`.progress()` Returns a float between 0 and 1 indicating the current upload progress of all files.
143
140
*`.isUploading()` Returns a boolean indicating whether or not the instance is currently uploading anything.
144
141
*`.addFile(file)` Add a HTML5 File object to the list of files.
145
-
*`.removeFile(file)` Cancel upload of a specific `ResumableFile` object on the list from the list.
146
-
*`.getFromUniqueIdentifier(uniqueIdentifier)` Look up a `ResumableFile` object by its unique identifier.
142
+
*`.removeFile(file)` Cancel upload of a specific `FlowFile` object on the list from the list.
143
+
*`.getFromUniqueIdentifier(uniqueIdentifier)` Look up a `FlowFile` object by its unique identifier.
147
144
*`.getSize()` Returns the total size of the upload in bytes.
148
145
149
146
#### Events
@@ -152,43 +149,43 @@ set singleFile to true.
152
149
*`.fileProgress(file)` Uploading progressed for a specific file.
153
150
*`.fileAdded(file, event)` This event is used for file validation. To reject this file return false.
154
151
This event is also called before file is added to upload queue,
155
-
this means that calling `Resumable.upload()` function will not start current file upload.
152
+
this means that calling `flow.upload()` function will not start current file upload.
156
153
Optionally, you can use the browser `event` object from when the file was
157
154
added.
158
155
*`.filesAdded(array, event)` Same as fileAdded, but used for multiple file validation.
159
156
*`.filesSubmitted(array, event)` Can be used to start upload of currently added files.
160
157
*`.fileRetry(file)` Something went wrong during upload of a specific file, uploading is being retried.
161
158
*`.fileError(file, message)` An error occured during upload of a specific file.
162
-
*`.uploadStart()` Upload has been started on the Resumable object.
159
+
*`.uploadStart()` Upload has been started on the Flow object.
163
160
*`.complete()` Uploading completed.
164
161
*`.progress()` Uploading progress.
165
162
*`.error(message, file)` An error, including fileError, occured.
166
163
*`.catchAll(event, ...)` Listen to all the events listed above with the same callback function.
167
164
168
-
### ResumableFile
169
-
ResumableFile constructor can be accessed in `Resumable.ResumableFile`.
165
+
### FlowFile
166
+
FlowFile constructor can be accessed in `Flow.FlowFile`.
170
167
#### Properties
171
168
172
-
*`.resumableObj` A back-reference to the parent `Resumable` object.
169
+
*`.flowObj` A back-reference to the parent `Flow` object.
173
170
*`.file` The correlating HTML5 `File` object.
174
171
*`.fileName` The name of the file.
175
172
*`.relativePath` The relative path to the file (defaults to file name if relative path doesn't exist)
176
173
*`.size` Size in bytes of the file.
177
174
*`.uniqueIdentifier` A unique identifier assigned to this file object. This value is included in uploads to the server for reference, but can also be used in CSS classes etc when building your upload UI.
178
175
*`.averageSpeed` Average upload speed, bytes per second.
179
176
*`.currentSpeed` Current upload speed, bytes per second.
180
-
*`.chunks` An array of `ResumableChunk` items. You shouldn't need to dig into these.
177
+
*`.chunks` An array of `FlowChunk` items. You shouldn't need to dig into these.
181
178
*`.paused` Indicated if file is paused.
182
179
*`.error` Indicated if file has encountered an error.
183
180
184
181
#### Methods
185
182
186
-
*`.progress(relative)` Returns a float between 0 and 1 indicating the current upload progress of the file. If `relative` is `true`, the value is returned relative to all files in the Resumable.js instance.
183
+
*`.progress(relative)` Returns a float between 0 and 1 indicating the current upload progress of the file. If `relative` is `true`, the value is returned relative to all files in the Flow.js instance.
187
184
*`.pause()` Pause uploading the file.
188
185
*`.resume()` Resume uploading the file.
189
186
*`.cancel()` Abort uploading the file and delete it from the list of files to upload.
190
187
*`.retry()` Retry uploading the file.
191
-
*`.bootstrap()` Rebuild the state of a `ResumableFile` object, including reassigning chunks and XMLHttpRequest instances.
188
+
*`.bootstrap()` Rebuild the state of a `FlowFile` object, including reassigning chunks and XMLHttpRequest instances.
192
189
*`.isUploading()` Returns a boolean indicating whether file chunks is uploading.
193
190
*`.isComplete()` Returns a boolean indicating whether the file has completed uploading and received a server response.
194
191
*`.sizeUploaded()` Returns size uploaded in bytes.
@@ -209,11 +206,11 @@ To ensure consistency throughout the source code, keep these rules in mind as yo
@@ -242,3 +239,6 @@ Automated tests is running after every commit at travis-ci.
242
239
2.`grunt test --sauce-local=true --sauce-username=**** --sauce-access-key=***`
243
240
244
241
other browsers can be used with `--browsers` flag, available browsers: sl_opera,sl_iphone,sl_safari,sl_ie10,sl_chorme,sl_firefox
242
+
243
+
## Origin
244
+
Flow.js was inspired by and evolved from https://github.com/23/resumable.js. Library has been supplemented with tests and features, such as drag and drop for folders, upload speed, time remaining estimation, separate files pause, resume and more.
0 commit comments