Create a file message
Create a file message from a platform path with the OpenIM Flutter SDK.
Construct a file message object from a local filesystem file path:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | String | Yes | Local filesystem path to the file on the current device. |
fileName | String | Yes | Display name of the file shown to recipients (include the file extension, such as document.pdf). |
Code example
final message = await OpenIM.iMManager.messageManager.createFileMessage(
filePath: filePath,
fileName: fileName,
);The specified path must be an accessible file with read permissions on the current device.
Return value
Returns a Future resolving to a file Message object ready for transmission. Its file properties are stored in fileElem.
State changes after the call
Creating a message only constructs the local message data structure in memory; it does not perform network transmission, does not upload files, and does not trigger new-message event callbacks. Once constructed, pass the returned Message instance to Send a message, which handles file upload and message delivery. To create a file message from an absolute filesystem path, see Create a file message from full path; if the file is already hosted on object storage, see Create a file message by URL.
Was this page helpful?