Skip to content

Commit

Permalink
fix(upload): implement complete upload callback for improved file han…
Browse files Browse the repository at this point in the history
…dling
  • Loading branch information
cycleccc committed Dec 25, 2024
1 parent 46037d4 commit 2099e64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/rich-waves-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wangeditor-next/core": patch
"@wangeditor-next/editor": patch
---

fix(upload): add complete upload callback
8 changes: 5 additions & 3 deletions packages/core/src/upload/createUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ function createUploader(config: IUploadConfig): Uppy {
})

// 各个 callback
uppy.on('upload-success', (file, response) => {
const { body = {} } = response
// onSuccess 每个 file 上传成功都会触发,改用 complete 便于 files 上传
uppy.on('complete', result => {
const file = result.successful[0]
const { response } = file
const { body = {} } = response ?? {}

try {
// 有用户传入的第三方代码,得用 try catch 包裹
onSuccess(file, body)
} catch (err) {
console.error('wangEditor upload file - onSuccess error', err)
Expand Down

0 comments on commit 2099e64

Please sign in to comment.