Send files in chat
Users can transfer files to each other during a session.
Zoom deletes files sent through in-session chat when the session ends.
Prerequisites
Enable send files via in-session chat in your Video SDK account portal settings, and configure the following.
- Only allow specified file types. Allow only specific file types and enter the file extensions, separated by commas.
- Maximum file size. Limit the file size, up to 2048 MB.
At runtime, read these settings from the session. Check whether file transfer is enabled with isFileTransferEnable, get the allowed types with getTransferFileTypeWhiteList, and get the size limit with getMaxTransferFileSize.
IZoomVideoSDKSession* pSession = m_pVideoSDK->getSessionInfo();
if (!pSession) return;
if (pSession->isFileTransferEnable())
{
// Comma-separated list of allowed extensions, for example "pdf,jpg,png".
const zchar_t* allowedTypes = pSession->getTransferFileTypeWhiteList();
// Maximum allowed file size, in bytes.
uint64_t maxSize = pSession->getMaxTransferFileSize();
}
Send a file to everyone
To send a file to all users in the session, call transferFile on the session with the local path to the file.
IZoomVideoSDKSession* pSession = m_pVideoSDK->getSessionInfo();
if (pSession) {
ZoomVideoSDKErrors err = pSession->transferFile(L"C:\\path\\to\\file.pdf");
}
Send a file to a specific user
To send a file to one user, call transferFile on that user's IZoomVideoSDKUser.
if (pUser) {
ZoomVideoSDKErrors err = pUser->transferFile(L"C:\\path\\to\\document.txt");
}
Track send progress
The SDK reports progress for files you send through onSendFileStatus. Each call passes the IZoomVideoSDKSendFile and the current FileTransferStatus.
void CExampleListener::onSendFileStatus(IZoomVideoSDKSendFile* file, const FileTransferStatus& status)
{
if (!file) return;
if (status == FileTransferState_TransferDone) {
// The file was sent successfully.
} else if (status == FileTransferState_TransferFailed) {
// The transfer failed.
}
// To cancel an in-progress send:
// file->cancelSend();
}
Receive a file
The SDK reports incoming files through onReceiveFileStatus. Call startReceive with a local path to accept and save the file, or cancelReceive to reject it. Read the file's details from the inherited accessors, such as getFileName, getFileSize, and getSender.
void CExampleListener::onReceiveFileStatus(IZoomVideoSDKReceiveFile* file, const FileTransferStatus& status)
{
if (!file) return;
if (status == FileTransferState_ReadyToTransfer) {
// Accept the file and save it locally.
file->startReceive(L"C:\\Users\\Public\\Downloads\\ZoomFile.dat");
// Or reject it:
// file->cancelReceive();
}
}
File transfer status values
FileTransferStatus is one of the following values.
| Value | Meaning |
|---|---|
FileTransferState_None | No transfer is in progress. |
FileTransferState_ReadyToTransfer | The transfer is ready to begin. |
FileTransferState_Transfering | The file is currently transferring. |
FileTransferState_TransferFailed | The transfer failed. |
FileTransferState_TransferDone | The transfer completed successfully. |