# Send files in chat

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

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](/docs/build/account/#in-session-advanced) 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`.

```cpp
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.

```cpp
IZoomVideoSDKSession* pSession = m_pVideoSDK->getSessionInfo();
if (pSession) {
    ZoomVideoSDKErrors err = pSession->transferFile("/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`.

```cpp
if (pUser) {
    ZoomVideoSDKErrors err = pUser->transferFile("/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`.

```cpp
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`.

```cpp
void CExampleListener::onReceiveFileStatus(IZoomVideoSDKReceiveFile* file, const FileTransferStatus& status)
{
    if (!file) return;

    if (status == FileTransferState_ReadyToTransfer) {
        // Accept the file and save it locally.
        file->startReceive("/home/user/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. |
