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
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,22 @@ input.addEventListener('change', function (e) {
55
55
})
56
56
```
57
57
58
+
### Parallel Uploads with Progressive URL Saving
59
+
60
+
For better fault tolerance with parallel uploads, you can enable progressive URL saving:
61
+
62
+
```js
63
+
var upload =newtus.Upload(file, {
64
+
endpoint:'http://localhost:1080/files/',
65
+
parallelUploads:4,
66
+
progressiveUrlSaving:true, // Save each partial upload URL immediately
67
+
urlStorage: myThreadSafeStorage, // Your storage implementation
68
+
// ... other options
69
+
})
70
+
```
71
+
72
+
When enabled, partial upload URLs are saved immediately as each completes, rather than waiting for all to finish. This improves resumability if failures occur during parallel uploads. See the [API documentation](docs/api.md#progressiveurlsaving) for implementation details.
Copy file name to clipboardExpand all lines: docs/api.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,6 +248,47 @@ _Default value:_ `false`
248
248
249
249
A boolean indicating if the fingerprint in the URL storage will be removed once the upload is successfully completed. When this feature is enabled and the same file is uploaded again, it will create an entirely new upload instead of reusing the previous one. Furthermore, this option will only change behavior if `urlStorage` is not `null`.
250
250
251
+
#### progressiveUrlSaving
252
+
253
+
_Default value:_`false`
254
+
255
+
A boolean indicating whether partial upload URLs should be saved progressively during parallel uploads. When `false` (default), all partial upload URLs must be successfully created before any are saved to storage. When `true`, each partial upload URL is saved immediately after its POST request succeeds.
256
+
257
+
This option only has an effect when `parallelUploads` is greater than 1. Enabling this provides better fault tolerance for parallel uploads:
258
+
- If a browser crash or network failure occurs, successfully created partial uploads can still be resumed
259
+
- Earlier persistence reduces the window of data loss
260
+
- More granular progress tracking across sessions
261
+
262
+
When using this option, your `urlStorage` implementation should handle concurrent updates safely, especially if using a database backend. Consider using a mutex or other synchronization mechanism to prevent race conditions when multiple parallel uploads save their URLs simultaneously.
263
+
264
+
Example usage with a thread-safe storage implementation:
0 commit comments