Create a file message from a local path
Create a file message from an absolute path with the OpenIM Flutter SDK.
Construct a file message object from an absolute filesystem path on the local device:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | String | Yes | Absolute 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
.createFileMessageFromFullPath(
filePath: absolutePath,
fileName: fileName,
);The absolute path must exist and have read permissions on the current platform.
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 a relative platform path, see Create a file message; if the file is already hosted on object storage, see Create a file message by URL.
Was this page helpful?