SDKsHarmonyOSEnterprise
Create file message from local file
Create a file message from an accessible local filesystem path.
Creates a file message object using a local filesystem path accessible to the application.
Code example
import sdk, { CreateFileMessageReq, CreateFileMessageResp } from '@openimsdk/imsdk';
const request: CreateFileMessageReq = {
fileSourcePath: filePath,
fileName: 'ProjectPlan.pdf',
};
const response: CreateFileMessageResp = await sdk.createFileMessage(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fileSourcePath | string | Yes | Local filesystem path readable by the native SDK. |
fileName | string | Yes | File display name shown to receiving users, including extension. |
Return value
Returns a Promise resolving to CreateFileMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated file message object. |
State changes after the call
fileSourcePath must be accessible to the native SDK layer. fileName is displayed and saved by receiving clients and should preserve appropriate file extensions without substituting for real file content validation. Resolving the Promise creates the message object locally; calling Send message subsequently uploads the file through the SDK and sends the message.
Was this page helpful?