Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Version 4
Home
/
Chat
/
JavaScript
/
Message

Cancel an in-progress file upload

Copy link

Using the cancelUploadingFileMessage() method, you can cancel an in-progress file upload while it hasn't been completed yet. If the function operates successfully, the value of true is returned.

Note: If you attempt to cancel the upload after it has already been completed or canceled, or the attempt results in an error, the function returns the value of false.

const params: FileMessageCreateParams = {
    file: FILE,
    fileName: FILE_NAME,
    customType: CUSTOM_TYPE,
    data: DATA,
};
channel.sendFileMessage(params)
    .onPending((message: FileMessage) => {
        // ...
        channel.cancelUploadingFileMessage(message.reqId);
    });