SDKsHarmonyOSEnterprise
Create image message from local file
Create an image message from local filesystem image paths accessible to the application.
sourcePath must point to a stable local path accessible to the native HarmonyOS application. The optional bigPath and snapshotPath specify high-resolution and thumbnail images respectively; when omitted, the SDK falls back to the original image.
Code example
import sdk, { CreateImageMessageReq, CreateImageMessageResp } from '@openimsdk/imsdk';
const request: CreateImageMessageReq = {
sourcePath: imagePath,
bigPath: bigImagePath,
snapshotPath: thumbnailPath,
};
const response: CreateImageMessageResp = await sdk.createImageMessage(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sourcePath | string | Yes | Local filesystem path to the original image. |
bigPath | string | No | Optional local filesystem path to a compressed or high-res image variant. |
snapshotPath | string | No | Optional local filesystem path to a thumbnail snapshot image. |
Return value
Returns a Promise resolving to CreateImageMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated image message object. |
State changes after the call
Temporary paths may be purged by the system. If sending is deferred, copy files into persistent application sandbox storage first. Promise resolution creates the message object locally; calling Send message subsequently triggers upload and transmission by the SDK.
Was this page helpful?