Skip to content

Commit bf0bd38

Browse files
committed
docs: new features documented
1 parent d8dd388 commit bf0bd38

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ For every request, you can confirm reception in HTTP status codes (can be change
8383
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:
8484

8585
* 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.
8788

8889
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.
8990

@@ -113,6 +114,8 @@ function, it will be passed a FlowFile, a FlowChunk and isTest boolean (Default:
113114
include cookies as part of the request, you need to set the `withCredentials` property to true.
114115
(Default: `false`)
115116
* `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`)
116119
* `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`)
117120
* `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`)
118121
* `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`)
125128
and average upload speed wil be equal to current upload speed. For longer file uploads it is
126129
better set this number to 0.02, because time remaining estimation will be more accurate. This
127130
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]`)
128134

129135

130136
#### Properties
@@ -166,21 +172,24 @@ parameter must be adjusted together with `progressCallbacksInterval` parameter.
166172

167173
#### Events
168174

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.
171179
* `.fileAdded(file, event)` This event is used for file validation. To reject this file return false.
172180
This event is also called before file is added to upload queue,
173181
this means that calling `flow.upload()` function will not start current file upload.
174182
Optionally, you can use the browser `event` object from when the file was
175183
added.
176184
* `.filesAdded(array, event)` Same as fileAdded, but used for multiple file validation.
177185
* `.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.
180189
* `.uploadStart()` Upload has been started on the Flow object.
181190
* `.complete()` Uploading completed.
182191
* `.progress()` Uploading progress.
183-
* `.error(message, file)` An error, including fileError, occurred.
192+
* `.error(message, file, chunk)` An error, including fileError, occurred.
184193
* `.catchAll(event, ...)` Listen to all the events listed above with the same callback function.
185194

186195
### FlowFile

0 commit comments

Comments
 (0)