Cancel file upload
Terminate an in-progress file upload task using its cancellation identifier.
Generate a unique cancellation identifier before initiating an upload and store it alongside your application upload task. Concurrent uploads must use distinct IDs.
Code example
import sdk, { CancelUploadReq } from '@openimsdk/imsdk';
const request: CancelUploadReq = { cancelID: cancelID };
await sdk.cancelUpload(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cancelID | string | Yes | The cancellation identifier originally assigned in the UploadFileReq. |
Return value
Returns a Promise that resolves to void when the cancellation instruction has been issued to the network pipeline.
State changes after the call
If the upload task has already concluded, the cancelID does not exist, or the server already received the entire payload, the final outcome depends on the current pipeline state. Application logic should handle rejection on the original uploadFile() Promise and prevent subsequent profile or message updates. For initiating uploads and tracking progress, see Upload file. Cancelling an upload does not delete remote files that were already committed to storage, nor does it revoke any previously dispatched messages.
Was this page helpful?