> Markdown version of [Flow Usage](https://vaadin.com/docs/v23/components/upload/flow). Section index: [llms.txt](https://vaadin.com/docs/v23/components/llms.txt)

# Using Upload in Flow

## <a id="defining-a-receiver-instance"></a>Defining a Receiver Instance

A `Receiver` instance should be specified to receive uploaded data. The receiver provides an `OutputStream` for the framework, where it writes the content of the received file. You can implement the interface directly, or use the prebuilt helpers that buffer the file content for later access.

The built-in implementations of `Receiver` are:

- `FileBuffer`

- `MemoryBuffer`

- `MultiFileBuffer`

- `MultiFileMemoryBuffer`.

The last two implement `MultiFileReceiver` and can be used to upload multiple files at once.

**Example**: Simple `Receiver` instance that allows uploading of one file.

```java
MemoryBuffer memoryBuffer = new MemoryBuffer();

Upload upload = new Upload(memoryBuffer);
upload.addFinishedListener(e -> {
    InputStream inputStream = memoryBuffer.getInputStream();
    // read the contents of the buffered memory
    // from inputStream
});
```

- The uploaded data is stored in a file on the file system.

- You can read the data using the `getInputStream()` method in `MemoryBuffer` when the upload is finished.

You can use a `MultiFileReceiver` to allow uploading of more than one file.

**Example**: Using `MultiFileMemoryBuffer`

```java
MultiFileMemoryBuffer multiFileMemoryBuffer = new MultiFileMemoryBuffer();
Upload upload = new Upload(multiFileMemoryBuffer);
```

- The `MultiFileMemoryBuffer` class is a ready-made implementation of `MultiFileReceiver`.

- The data is stored in files on the file system and you can get the data using a file name and the `getInputStream(String)` method.

## <a id="setting-maximum-files"></a>Setting Maximum Files

You can limit the number of files that can be uploaded at a time using the `setMaxFiles()` method.

`EB618652-4822-49DC-9A51-D71237EF100E`
