SDKsAndroid
Create a file message from a local path
Create a file message from an absolute path.
Construct a file message object using an absolute filesystem path on the local device (such as a document picked from the system file picker). When sending via Send a message, the SDK reads the local file and automatically performs the upload.
Code example
String absolutePath = "/storage/emulated/0/Download/specs.docx";
String fileName = "Requirements_Specification.docx";
Message message = OpenIMClient.getInstance().messageManager.createFileMessageFromFullPath(
absolutePath,
fileName
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | String | Yes | Absolute filesystem path of the file on the local device. Ensure read permissions are granted. |
fileName | String | Yes | Display name of the file presented to recipients (including file extension). |
Return value
Returns the created Message object with contentType set to MessageType.FILE.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without starting network uploads. - Transmission: Call Send a message to deliver the file message to a single user or group.
Was this page helpful?