SDKsHarmonyOSEnterprise
Create video message from URL
Create a video message from pre-uploaded video and cover thumbnail resource metadata.
Creates a video message object using remote URLs and metadata for both video and thumbnail cover assets.
Code example
import sdk, { CreateVideoMessageByURLReq, CreateVideoMessageResp } from '@openimsdk/imsdk';
const request: CreateVideoMessageByURLReq = {
videoPath: '',
videoUUID: uploadedVideo.uuid,
videoURL: uploadedVideo.url,
videoType: 'video/mp4',
videoSize: uploadedVideo.size,
duration: 18,
snapshotPath: '',
snapshotUUID: uploadedCover.uuid,
snapshotSize: uploadedCover.size,
snapshotURL: uploadedCover.url,
snapshotWidth: 1280,
snapshotHeight: 720,
snapshotType: 'image/jpeg',
};
const response: CreateVideoMessageResp = await sdk.createVideoMessageByURL(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoPath | string | Yes | Local video path if retained, or empty string "" for remote files. |
videoUUID | string | Yes | Unique identifier for the video asset. |
videoURL | string | Yes | Remote video download URL. |
videoType | string | Yes | Video MIME type (such as video/mp4). |
videoSize | number | Yes | Video file size in bytes. |
duration | number | Yes | Video playback duration in seconds. |
snapshotPath | string | Yes | Local thumbnail path if retained, or empty string "". |
snapshotUUID | string | Yes | Unique identifier for the cover thumbnail asset. |
snapshotSize | number | Yes | Cover thumbnail file size in bytes. |
snapshotURL | string | Yes | Remote thumbnail download URL. |
snapshotWidth | number | Yes | Thumbnail pixel width. |
snapshotHeight | number | Yes | Thumbnail pixel height. |
snapshotType | string | Yes | Thumbnail MIME type (such as image/jpeg). |
Return value
Returns a Promise resolving to CreateVideoMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated video message object referencing remote URLs. |
State changes after the call
Note that property names use uppercase URL. All sizes, dimensions, types, and durations must match actual resource attributes; even if no local files exist, pass empty strings "" for videoPath and snapshotPath. This method instantiates the message object locally; call Send message to dispatch it.
Was this page helpful?