Skip to main content

sendChatFileMessage(fileS3Key, fileName, fileMimeType, fileSizeBytes)

Send a file message to everyone

caution

join() must be called before calling this method

Sends a file message that references a file you have already uploaded. Sharing a file is a two-step flow: first upload the file, then send the message that points to it.

First, upload the file to POST /api/v1/chat/upload using the chat access token from getChatAccessToken(). The response contains fileS3Key, fileName, fileMimeType and fileSizeBytes.

JavaScript
const body = new FormData();
body.append("file", file);

const res = await fetch("https://<your-app>.metered.live/api/v1/chat/upload", {
method: "POST",
headers: { Authorization: `Bearer ${meeting.getChatAccessToken()}` },
body,
});
const { fileS3Key, fileName, fileMimeType, fileSizeBytes } = await res.json();

meeting.sendChatFileMessage(fileS3Key, fileName, fileMimeType, fileSizeBytes);

Recipients receive the message through the chatMessageReceived event with a type of "file" or "image" and a downloadToken used to fetch the file.

See Chat file sharing for the REST upload and download endpoints.