createFileMessage
Introduction
Create a message that carry a file.
For Android and iOS, you are supposed to provide the local absolute path of the file.
For Web, you should provide the input DOM element, with file selected.
Demo code shows here.
For details, you can referring to this document.
Parameter details
Parameter name | Parameter type | Required | Platform | Description |
---|---|---|---|---|
filePath | String | yes | All | The local absolute path to the file, used on Android and iOS. |
fileName | String | yes | All | The file name. |
inputElement | dynamic | no | All | The DOM element of the input, used for Web. |
Returned template
V2TimValueCallback<V2TimMsgCreateInfoResult>
{
code: int,
desc: String,
data: {
id: String,
messageInfo: V2TimMessage,
}
}
Return value details
name | type | description |
---|---|---|
code | int | Request result: Error codes. 0 means success. |
desc | String | The description of the failure. |
data | V2TimMsgCreateInfoResult | The file message created. |
Code example
V2TimValueCallback<V2TimMsgCreateInfoResult> createFileMessageRes =
await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createFileMessage(
filePath: "file path",
fileName: "file name",
);
if (createFileMessageRes.code == 0) {
String id = createFileMessageRes.data.id;
V2TimValueCallback<V2TimMessage> sendMessageRes = await TencentImSDKPlugin
.v2TIMManager
.getMessageManager()
.sendMessage(id: id, receiver: "userID", groupID: "groupID");
if (sendMessageRes.code == 0) {
}
}