From 1fc9e7e0e25db828e8bede27c2ac5b52e7571368 Mon Sep 17 00:00:00 2001 From: cgoing Date: Thu, 7 Sep 2023 23:40:41 +0900 Subject: [PATCH] @uppy/tus onSuccess, onError, and onProgress --- packages/@uppy/tus/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/tus/src/index.js b/packages/@uppy/tus/src/index.js index 377c74c7e6..5746d3c64a 100644 --- a/packages/@uppy/tus/src/index.js +++ b/packages/@uppy/tus/src/index.js @@ -250,12 +250,14 @@ export default class Tus extends BasePlugin { queuedRequest?.abort() this.uppy.emit('upload-error', file, err) - + if (typeof opts.onError === 'function') opts.onError(err); reject(err) } uploadOptions.onProgress = (bytesUploaded, bytesTotal) => { this.onReceiveUploadUrl(file, upload.url) + if (typeof opts.onProgress === 'function') + opts.onProgress(bytesUploaded, bytesTotal); this.uppy.emit('upload-progress', file, { uploader: this, bytesUploaded, @@ -276,6 +278,7 @@ export default class Tus extends BasePlugin { if (upload.url) { this.uppy.log(`Download ${upload.file.name} from ${upload.url}`) } + if (typeof opts.onSuccess === 'function') opts.onSuccess(); resolve(upload) }