SDKsHarmonyOSEnterprise
Create image message from URL
Create an image message from pre-uploaded image resource metadata.
Original, high-resolution, and thumbnail variants can reference different URLs. Reuse identical metadata only when all three images actually share the same asset.
Code example
import sdk, {
CreateImageMessageByURLReq,
CreateImageMessageResp,
PictureBaseInfo,
} from '@openimsdk/imsdk';
const picture: PictureBaseInfo = {
uuid: uploaded.uuid,
type: 'image/jpeg',
size: uploaded.size,
width: 1280,
height: 720,
url: uploaded.url,
};
const request: CreateImageMessageByURLReq = {
sourcePicture: picture,
bigPicture: picture,
snapshotPicture: picture,
};
const response: CreateImageMessageResp = await sdk.createImageMessageByURL(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sourcePicture | PictureBaseInfo | Yes | Original image metadata including URL, dimensions, and size. |
bigPicture | PictureBaseInfo | Yes | High-resolution or compressed image variant metadata. |
snapshotPicture | PictureBaseInfo | Yes | Thumbnail image metadata. |
Return value
Returns a Promise resolving to CreateImageMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated image message object referencing remote URLs. |
State changes after the call
URL, MIME type, size, and dimensions must originate from verified upload responses. sourcePath, bigPath, and snapshotPath inside PictureBaseInfo are optional and only needed if retaining local paths. Call Send message after creation; the SDK automatically recognizes pre-existing remote asset URLs.
Was this page helpful?