Skip to main content

createVideoMessageByFile

Feature Introduction

Note

Create video message

Attention

Supported only on the web platform. It is recommended not to use for large file uploads. For files larger than 1GB, it's recommended to use the createVideoMessageByURL interface.

Function Prototype

IMSDK.createVideoMessageByFile({
videoPath: string;
duration: number;
videoType: string;
snapshotPath: string;
videoUUID: string;
videoUrl: string;
videoSize: number;
snapshotUUID: string;
snapshotSize: number;
snapshotUrl: string;
snapshotWidth: number;
snapshotHeight: number;
snapShotType: string;
videoFile: File;
snapshotFile: File;
}, operationID?: string): Promise<WsResponse<MessageItem>>

Input Parameters

Parameter NameData TypeMandatoryDescription
videoPathstringYesAbsolute file path, pass an empty string if not available.
durationnumberYesVideo duration.
videoTypestringYesFile type, generally the file extension.
snapshotPathstringYesVideo thumbnail path, pass an empty string if not available.
videoUUIDstringYesUnique ID for the video file.
videoUrlstringYesVideo download URL. If uploading yourself and sending via sendMessageNotOss, input the remote URL. Otherwise, use an empty string.
videoSizenumberYesFile size.
snapshotUUIDstringYesUnique ID for the video thumbnail.
snapshotSizenumberYesSize of the video thumbnail.
snapshotUrlstringYesDownload URL for the video thumbnail. If uploading yourself and sending via sendMessageNotOss, input the remote URL. Otherwise, use an empty string.
snapshotWidthnumberYesWidth of the video thumbnail.
snapshotHeightnumberYesHeight of the video thumbnail.
snapShotTypestringYesType of the video thumbnail, generally the file extension.
videoFileFileYesVideo file object.
snapshotFileFileYesVideo thumbnail file object.

Return Result

Parameter NameData TypeDescription
Promise.then()Promise<WsResponse<MessageItem>>Successful callback
Promise.catch()Promise<WsResponse>Failure callback

Code Example

import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();

// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();

// use in mini program
// import { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();

IMSDK.createVideoMessageByFile({
videoPath: videoFile.path,
duration: 6,
videoType: videoFile.type,
snapshotPath: snapshotFile.path,
videoUUID: '',
videoUrl: '',
videoSize: videoFile.size,
snapshotUUID: '',
snapshotSize: snapshotFile.size,
snapshotUrl: '',
snapshotWidth: 1024,
snapshotHeight: 1024,
snapShotType: snapshotFile.type,
videoFile,
snapshotFile,
})
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});