Send files in chat
Users can transfer files in chat during the session.
Zoom deletes files sent via in-session chat when the session ends.
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 if the file transfer feature is enabled.
let ret = ZMVideoSDK.shared().getSessionInfo().isFileTransferEnabled()
BOOL ret = [[[ZMVideoSDK sharedVideoSDK] getSessionInfo] isFileTransferEnabled];
Get the list of allowed file types that you can transfer.
let ret = ZMVideoSDK.shared().getSessionInfo().getTransferFileTypeWhiteList()
NSString *ret = [[[ZMVideoSDK sharedVideoSDK] getSessionInfo] getTransferFileTypeWhiteList];
Get the maximum file size to transfer.
let ret = ZMVideoSDK.shared().getSessionInfo().getMaxTransferFileSize()
unsigned long long ret = [[[ZMVideoSDK sharedVideoSDK] getSessionInfo] getMaxTransferFileSize];
Send files to all users in the current session.
let ret = ZMVideoSDK.shared().getSessionInfo().transferFile(filePath: String)
ZMVideoSDKErrors ret = [[[ZMVideoSDK sharedVideoSDK] getSessionInfo] transferFile:self.filePathTextF.stringValue];
Send files to a certain user in the session.
// Locate the user that you would like to send the file to.
let receiver: ZMVideoSDKUser
// Send file directly.
let ret = receiver.transferFile(filePath: String)
ZMVideoSDKErrors ret = [_receiverUser transferFile:self.filePathTextF.stringValue];
Cancel sending files.
// getCurrentSendFileObj is a user-defined method, to retrieve the sending file.
let sendFile: ZMVideoSDKSendFile = getCurrentSendFileObj()
let ret = sendFile.cancelSend()
ZMVideoSDKSendFile *send = [self getCurrentSendFileObj]; // getCurrentSendFileObj is a user-defined method, to retrieve the sending file.
ZMVideoSDKErrors ret = [send cancelSend];
Start receiving files.
// getCurrentReceiveFileObj is a user-defined method, to retrieve the receiving file.
let receiveFile: ZMVideoSDKReceiveFile = getCurrentReceiveFileObj()
let fileDomain = FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask).map(\.path).last
let filePath = "<File path to receive>"
let downloadFilePath = "\(fileDomain)/\(filePath.count > 0 ? filePath : receiveFile.fileName)"
if (receiveFile) {
let ret = receiveFile.startReceive(downloadFilePath)
}
ZMVideoSDKReceiveFile *receive = [self getCurrentReceiveFileObj]; //getCurrentReceiveFileObj is a user-defined method, to retrieve the receiving file.
NSString *fileDomain = [NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES).lastObject copy];
NSString *filePath = @"<File path to receive>";
NSString *downloadFilePath = [NSString stringWithFormat:@"%@/%@",fileDomain,filePath.length>0?filePath:receive.fileName];
if (receive) {
ZMVideoSDKErrors ret = [receive startReceive:downloadFilePath];
} else {
NSLog(@"receive is null");
}
Cancel receiving files.
// getCurrentReceiveFileObj is a user-defined method, to retrieve the receiving file.
let receiveFile: ZMVideoSDKReceiveFile = getCurrentReceiveFileObj()
if (receiveFile) {
let ret = receiveFile.cancelReceive()
}
ZMVideoSDKReceiveFile *receive = [self getCurrentReceiveFileObj]; // getCurrentReceiveFileObj is a user-defined method, to retrieve the receiving file.
if (receive) {
ZMVideoSDKErrors ret = [receive cancelReceive];
} else {
NSLog(@"receive is null");
}
File transfer callbacks
Be sure that you have set up a delegate for callback events to receive file transfer callbacks.
Get notified when you transfer a file.
func onSendFile(_ sendFile: ZMVideoSDKSendFile!, status: ZMVideoSDKFileTransferStatus) {
// Get the transfer status of the file and the file content here.
}
- (void)onSendFile:(ZMVideoSDKSendFile *)sendFile status:(ZMVideoSDKFileTransferStatus)status
{
// Get the transfer status of the file and the file content here.
}
Get notified when you receive a file from other users.
func onReceiveFile(_ receiveFile: ZMVideoSDKReceiveFile!, status: ZMVideoSDKFileTransferStatus) {
// Get the transfer status of the file and the file content here.
}
-(void)onReceiveFile:(ZMVideoSDKReceiveFile *)receiveFile status:(ZMVideoSDKFileTransferStatus)status
{
// Get the transfer status of the file and the file content here.
}