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.
- Browser/Electron/MiniProgram
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 Name | Data Type | Mandatory | Description |
---|---|---|---|
videoPath | string | Yes | Absolute file path, pass an empty string if not available. |
duration | number | Yes | Video duration. |
videoType | string | Yes | File type, generally the file extension. |
snapshotPath | string | Yes | Video thumbnail path, pass an empty string if not available. |
videoUUID | string | Yes | Unique ID for the video file. |
videoUrl | string | Yes | Video download URL. If uploading yourself and sending via sendMessageNotOss, input the remote URL. Otherwise, use an empty string. |
videoSize | number | Yes | File size. |
snapshotUUID | string | Yes | Unique ID for the video thumbnail. |
snapshotSize | number | Yes | Size of the video thumbnail. |
snapshotUrl | string | Yes | Download URL for the video thumbnail. If uploading yourself and sending via sendMessageNotOss, input the remote URL. Otherwise, use an empty string. |
snapshotWidth | number | Yes | Width of the video thumbnail. |
snapshotHeight | number | Yes | Height of the video thumbnail. |
snapShotType | string | Yes | Type of the video thumbnail, generally the file extension. |
videoFile | File | Yes | Video file object. |
snapshotFile | File | Yes | Video thumbnail file object. |
Return Result
Parameter Name | Data Type | Description |
---|---|---|
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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
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
});