Skip to main content

createVideoMessageByFile

Description

info

Create a video message based on a file object.

Note

Only supported on the Web side, and it is best not to use it for large file uploads. For files larger than 1G, it is recommended to use the createVideoMessageByURL API.

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 NameParameter TypeRequiredDescription
videoPathstringYesAbsolute file path, if none, empty string is fine
durationnumberYesVideo duration
videoTypestringYesFile type, usually the extension
snapshotPathstringYesVideo thumbnail path, empty string is fine
videoUUIDstringYesUnique video file ID
videoUrlstringYesVideo download address. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string
videoSizenumberYesFile size
snapshotUUIDstringYesUnique video thumbnail ID
snapshotSizenumberYesVideo thumbnail size
snapshotUrlstringYesVideo thumbnail download address. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string
snapshotWidthnumberYesVideo thumbnail width
snapshotHeightnumberYesVideo thumbnail height
snapShotTypestringYesVideo thumbnail type, usually the extension
videoFileFileYesVideo file object
snapshotFileFileYesVideo thumbnail file object

Return Result

Parameter NameParameter TypeDescription
Promise.then()Promise<WsResponse<MessageItem>>Success 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 }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});