Browse SDKs · WASM
SDKsWASM

Create a video message from files

Create a video message from browser video and snapshot files with the WASM SDK.

Copy

createVideoMessageByFile() creates a message from browser video and snapshot files and their metadata.

Parameters

ParameterTypeRequiredDescription
videoFileFileYesOriginal video file from the browser.
snapshotFileFileYesVideo snapshot file from the browser.
videoPathstringYesLocal filename or application-defined path of the video file.
durationnumberYesVideo duration.
videoTypestringYesVideo MIME type.
videoUUIDstringYesUnique identifier for the video resource.
videoUrlstringYesVideo URL. Pass an empty string when creating from a file.
videoSizenumberYesVideo size in bytes.
snapshotPathstringYesLocal filename or application-defined path of the snapshot file.
snapshotUUIDstringYesUnique identifier for the snapshot resource.
snapshotSizenumberYesSnapshot size in bytes.
snapshotUrlstringYesSnapshot URL. Pass an empty string when creating from a file.
snapshotWidthnumberYesSnapshot width in pixels.
snapshotHeightnumberYesSnapshot height in pixels.
snapShotTypestringNoSnapshot MIME type.
const { data: message } = await openimsdk.createVideoMessageByFile({
  videoFile,
  snapshotFile,
  videoPath: videoFile.name,
  duration,
  videoType: videoFile.type,
  videoUUID: crypto.randomUUID(),
  videoUrl: '',
  videoSize: videoFile.size,
  snapshotPath: snapshotFile.name,
  snapshotUUID: crypto.randomUUID(),
  snapshotSize: snapshotFile.size,
  snapshotUrl: '',
  snapshotWidth,
  snapshotHeight,
  snapShotType: snapshotFile.type,
});

When the Promise resolves, it has created only a pending message object. Use sendMessage() afterward to upload and send it.