Fix: Utilize user-defined onSuccess, onError, and onProgress callbacks in @uppy/tus (#4674)

* @uppy/tus onSuccess, onError, and onProgress

* @uppy/tus Fix ESLint issues

* @uppy/tus Fix ESLint issues

* @uppy/tus Fix ESLint issues
This commit is contained in:
choi sung keun 2023-09-19 04:51:26 +09:00 committed by GitHub
parent 0acb99e371
commit e400d4ccbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -250,12 +250,17 @@ 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 +281,9 @@ 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)
}