Send files in chat

Users can transfer files in chat during the session.

Note

Zoom deletes files sent via 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 settings.

  • Only allow specified file types - Select to allow only specific file types and enter the file extensions in the text box, separated by commas.
  • Maximum file size - Select to limit the file size to 2048 MB.

Check whether the file transfer feature is enabled.

if let isFileTransferEnable = ZoomVideoSDK.shareInstance()?.getSession()?.isFileTransferEnable(), isFileTransferEnable {
    // File transfer is enabled.
}
if ([[[ZoomVideoSDK shareInstance] getSession] isFileTransferEnable]) {
    // File transfer is enabled.
}

Get the list of allowed file types that you can transfer.

if let fileType = ZoomVideoSDK.shareInstance()?.getSession()?.getTransferFileTypeWhiteList() {
    // fileType is a string of the allowed file types, multiple values separated by comma. Exe files are forbidden by default.
}
NSString *fileType = [[[ZoomVideoSDK shareInstance] getSession] getTransferFileTypeWhiteList];
// fileType is a string of the allowed file types, multiple values separated by comma. Exe files are forbidden by default.

Get the maximum file size to transfer.

if let maxSize = ZoomVideoSDK.shareInstance()?.getSession()?.getMaxTransferFileSize() {
    // maxSize is the maximum allowed file size.
}
NSUInteger maxSize = [[[ZoomVideoSDK shareInstance] getSession] getMaxTransferFileSize];
// maxSize is the maximum allowed file size.

Send a file to everyone

Send a file to all users in the current session.

if let session = ZoomVideoSDK.shareInstance()?.getSession() {
    let error = session.transferFile("filePath")
    if error == .Errors_Success {
        // Transfer started successfully.
    } else {
        // Failed to transfer.
    }
}
ZoomVideoSDKSession *session = [[ZoomVideoSDK shareInstance] getSession];
ZoomVideoSDKError error = [session transferFile:@"filePath"];
if (error == Errors_Success) {
    // Transfer started successfully.
} else {
    // Failed to transfer.
}

Send a file to a specific user

Send a file to a certain user in the session.

// Get the user you want to send the file to.
let userToReceiveFile: ZoomVideoSDKUser
let error = userToReceiveFile.transferFile("filePath")
if error == .Errors_Success {
    // Transfer started successfully.
} else {
    // Failed to transfer.
}
// Get the user you want to send the file to.
ZoomVideoSDKUser *userToReceiveFile;
ZoomVideoSDKError error = [userToReceiveFile transferFile:@"filePath"];
if (error == Errors_Success) {
    // Transfer started successfully.
} else {
    // Failed to transfer.
}

Track send progress

Implement onSendFileStatus on your ZoomVideoSDKDelegate to track an outgoing transfer. Read the percentage from the file's getStatus().transProgress.ratio, and cancel a transfer that is still in progress by calling cancelSend on the ZoomVideoSDKSendFile.

func onSendFileStatus(_ file: ZoomVideoSDKSendFile?, status: ZoomVideoSDKFileTransferStatus) {
    guard let sendingFile = file else { return }
    switch status {
    case .FileTransferState_Transfering:
        // Transfer in progress. ratio is the percentage sent (0–100).
        let ratio = sendingFile.getStatus()?.transProgress?.ratio ?? 0
        // Update your progress UI. To stop while still sending, call cancelSend.
        // let error = sendingFile.cancelSend()
    case .FileTransferState_TransferDone:
        // The file was sent.
        break
    case .FileTransferState_TransferFailed:
        // The transfer failed. Surface an error and let the user retry.
        break
    default:
        break
    }
}
- (void)onSendFileStatus:(ZoomVideoSDKSendFile *)file status:(ZoomVideoSDKFileTransferStatus)status {
    if (!file) { return; }
    switch (status) {
        case FileTransferState_Transfering: {
            // Transfer in progress. ratio is the percentage sent (0–100).
            NSUInteger ratio = [file getStatus].transProgress.ratio;
            // Update your progress UI. To stop while still sending, call cancelSend.
            // [file cancelSend];
            break;
        }
        case FileTransferState_TransferDone:
            // The file was sent.
            break;
        case FileTransferState_TransferFailed:
            // The transfer failed. Surface an error and let the user retry.
            break;
        default:
            break;
    }
}

Receive a file

Implement onReceiveFileStatus on your ZoomVideoSDKDelegate. The first callback arrives with FileTransferState_ReadyToTransfer — that is your cue to prompt the user, then call startReceive on the ZoomVideoSDKReceiveFile to begin downloading the file to a path you choose, or cancelReceive to decline it.

func onReceiveFileStatus(_ file: ZoomVideoSDKReceiveFile?, status: ZoomVideoSDKFileTransferStatus) {
    guard let receiveFile = file else { return }
    switch status {
    case .FileTransferState_ReadyToTransfer:
        // A file is offered. Prompt the user, then accept by downloading to a path you choose...
        let error = receiveFile.startReceive(filePath)
        // ...or decline:
        // let error = receiveFile.cancelReceive()
    case .FileTransferState_Transfering:
        // ratio is the percentage downloaded (0–100).
        let ratio = receiveFile.getStatus()?.transProgress?.ratio ?? 0
        // Update your progress UI.
    case .FileTransferState_TransferDone:
        // The file finished downloading.
        break
    case .FileTransferState_TransferFailed:
        // The transfer failed. Surface an error and let the user retry.
        break
    default:
        break
    }
}
- (void)onReceiveFileStatus:(ZoomVideoSDKReceiveFile *)file status:(ZoomVideoSDKFileTransferStatus)status {
    if (!file) { return; }
    switch (status) {
        case FileTransferState_ReadyToTransfer: {
            // A file is offered. Prompt the user, then accept by downloading to a path you choose...
            ZoomVideoSDKError error = [file startReceive:filePath];
            // ...or decline:
            // ZoomVideoSDKError error = [file cancelReceive];
            break;
        }
        case FileTransferState_Transfering: {
            // ratio is the percentage downloaded (0–100).
            NSUInteger ratio = [file getStatus].transProgress.ratio;
            // Update your progress UI.
            break;
        }
        case FileTransferState_TransferDone:
            // The file finished downloading.
            break;
        case FileTransferState_TransferFailed:
            // The transfer failed. Surface an error and let the user retry.
            break;
        default:
            break;
    }
}

Be sure that you have set up a delegate for callback events to receive these callbacks.

File transfer status values

Both onSendFileStatus and onReceiveFileStatus report where a transfer is in its lifecycle through ZoomVideoSDKFileTransferStatus.

StatusMeaningWhat to do
FileTransferState_NoneNo transfer activity.Nothing.
FileTransferState_ReadyToTransferAn incoming file is ready to download.Prompt the user, then call startReceive to accept or cancelReceive to decline.
FileTransferState_TransferingThe transfer is in progress.Read getStatus().transProgress.ratio (0–100) to drive a progress UI. Call cancelSend or cancelReceive to stop.
FileTransferState_TransferDoneThe transfer completed.The file is sent or saved; finalize your UI.
FileTransferState_TransferFailedThe transfer failed.Surface an error and let the user retry.