Cancel a file upload
Abort an active file upload task using its cancellation identifier.
When initiating an upload with Upload a file, supply a unique cancelID. You can subsequently invoke cancelUpload() with that same identifier to abort the in-flight transfer. The client runtime uses cancelID to target and terminate the specific upload task.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cancelID | string | Yes | The unique cancellation identifier provided when the upload was initiated. |
Code example
import { cancelUpload } from '@/uni_modules/unix-openim-sdk'
await cancelUpload({ cancelID })Generate cancelID prior to calling uploadFile(), and associate it with your local task state. Do not use filenames or array indices as task identifiers. For concurrent uploads, assign an independent cancelID to each file.
Return value
The Promise resolves with void once the SDK submits the cancellation signal to the native layer. If the upload has already finished, the cancelID does not exist, or the remote server has already processed the entire payload, outcome depends on the current transfer state. Rely on the rejection of the original upload Promise to update your UI, and avoid persisting partial avatars or attachments once cancelled.
State changes after the call
Aborting an upload terminates data transmission; it does not delete previously saved remote resources on the storage server or recall already transmitted messages. For full upload parameters and progress tracking, see Upload a file.
Was this page helpful?