createFileMessage

Introduction

Create a file message.

For details, you can referring to this document.

Parameter details

Parameter name Parameter type Required Description
filePath string yes The local absolute path to the file
fileName string yes The file name.

Returned template

V2TimValueCallback<V2TimMsgCreateInfoResult>

{
    code: number,
    desc: string,
    data: {
        id: string,
        messageInfo: V2TimMessage,
    }
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.
data V2TimMsgCreateInfoResult The file message created.

Code example

import { TencentImSDKPlugin } from 'react-native-tim-js';


const createFileMessageRes = await TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .createFileMessage(
        '本地文件绝对路径',
        '文件名'
    );
if (createFileMessageRes.code === 0) {
    const id = createFileMessageRes.data?.id;




    const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
        .getMessageManager()
        .sendMessage({ id: id!, receiver: 'userID', groupID: 'groupID' });
    if (sendMessageRes.code === 0) {

    }
}

results matching ""

    No results matching ""