SDKsAndroid
Create a file message
Create a file message from a path relative to the SDK data directory.
Construct a file message object using a relative path within the SDK initialization data directory. When sending via Send a message, the SDK automatically uploads the file and tracks transfer progress.
Code example
String filePath = "documents/annual_report.pdf";
String fileName = "Annual_Report.pdf";
Message message = OpenIMClient.getInstance().messageManager.createFileMessage(
filePath,
fileName
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | String | Yes | File path relative to the SDK initialization data directory. |
fileName | String | Yes | Display name of the file (such as Annual_Report.pdf), used by the receiver for display and saving. |
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 upload and send the file. For absolute local filesystem paths, see Create a file message from a local path.
Was this page helpful?