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
Copy file name to clipboardExpand all lines: README.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,8 @@ For every request, you can confirm reception in HTTP status codes (can be change
83
83
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:
84
84
85
85
* If this request returns a `200` HTTP code, the chunks is assumed to have been completed.
86
-
* If the request returns anything else, the chunk will be uploaded in the standard fashion.
86
+
* If request returns a permanent error status, upload is stopped.
87
+
* If request returns anything else, the chunk will be uploaded in the standard fashion.
87
88
88
89
After this is done and `testChunks` enabled, an upload can quickly catch up even after a browser restart by simply verifying already uploaded chunks that do not need to be uploaded again.
89
90
@@ -113,6 +114,8 @@ function, it will be passed a FlowFile, a FlowChunk and isTest boolean (Default:
113
114
include cookies as part of the request, you need to set the `withCredentials` property to true.
114
115
(Default: `false`)
115
116
*`method` Method to use when POSTing chunks to the server (`multipart` or `octet`) (Default: `multipart`)
117
+
*`testMethod` HTTP method to use when chunks are being tested. If set to a function, it will be passed a FlowFile and a FlowChunk arguments. (Default: `GET`)
118
+
*`uploadMethod` HTTP method to use when chunks are being uploaded. If set to a function, it will be passed a FlowFile and a FlowChunk arguments. (Default: `GET`)
116
119
*`prioritizeFirstAndLastChunk` Prioritize first and last chunks of all files. This can be handy if you can determine if a file is valid for your service from only the first or last chunk. For example, photo or video meta data is usually located in the first part of a file, making it easy to test support from only the first chunk. (Default: `false`)
117
120
*`testChunks` Make a GET request to the server for each chunks to see if it already exists. If implemented on the server-side, this will allow for upload resumes even after a browser crash or even a computer restart. (Default: `true`)
118
121
*`preprocess` Optional function to process each chunk before testing & sending. Function is passed the chunk as parameter, and should call the `preprocessFinished` method on the chunk when finished. (Default: `null`)
@@ -125,6 +128,9 @@ to 0 to handle each progress callback. (Default: `500`)
125
128
and average upload speed wil be equal to current upload speed. For longer file uploads it is
126
129
better set this number to 0.02, because time remaining estimation will be more accurate. This
127
130
parameter must be adjusted together with `progressCallbacksInterval` parameter. (Default 0.1)
131
+
*`successStatuses` Response is success if response status is in this list (Default: `[200,201,
132
+
202]`)
133
+
*`permanentErrors` Response fails if response status is in this list (Default: `[404, 415, 500, 501]`)
128
134
129
135
130
136
#### Properties
@@ -166,21 +172,24 @@ parameter must be adjusted together with `progressCallbacksInterval` parameter.
166
172
167
173
#### Events
168
174
169
-
*`.fileSuccess(file, message)` A specific file was completed. First argument `file` is instance of `FlowFile`, second argument `message` contains server response. Response is always a string.
170
-
*`.fileProgress(file)` Uploading progressed for a specific file.
175
+
*`.fileSuccess(file, message, chunk)` A specific file was completed. First argument `file` is instance of `FlowFile`, second argument `message` contains server response. Response is always a string.
176
+
Third argument `chunk` is instance of `FlowChunk`. You can get response status by accessing xhr
177
+
object `chunk.xhr.status`.
178
+
*`.fileProgress(file, chunk)` Uploading progressed for a specific file.
171
179
*`.fileAdded(file, event)` This event is used for file validation. To reject this file return false.
172
180
This event is also called before file is added to upload queue,
173
181
this means that calling `flow.upload()` function will not start current file upload.
174
182
Optionally, you can use the browser `event` object from when the file was
175
183
added.
176
184
*`.filesAdded(array, event)` Same as fileAdded, but used for multiple file validation.
177
185
*`.filesSubmitted(array, event)` Can be used to start upload of currently added files.
178
-
*`.fileRetry(file)` Something went wrong during upload of a specific file, uploading is being retried.
179
-
*`.fileError(file, message)` An error occurred during upload of a specific file.
186
+
*`.fileRetry(file, chunk)` Something went wrong during upload of a specific file, uploading is being
187
+
retried.
188
+
*`.fileError(file, message, chunk)` An error occurred during upload of a specific file.
180
189
*`.uploadStart()` Upload has been started on the Flow object.
181
190
*`.complete()` Uploading completed.
182
191
*`.progress()` Uploading progress.
183
-
*`.error(message, file)` An error, including fileError, occurred.
192
+
*`.error(message, file, chunk)` An error, including fileError, occurred.
184
193
*`.catchAll(event, ...)` Listen to all the events listed above with the same callback function.
0 commit comments