# IRPCFileTransferStreaming.FileUploadBlock

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Streaming file upload](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/FileUploadBlock/

Badges: `Vault API / standard` `write` `session or assertion` `client streaming`

Uploads one block of a stateless file upload by streaming its data.

The file is started with FileUploadBegin, its blocks are uploaded with this method and the file is
completed with FileUploadEnd (IRPCFileTransfer). The block data is sent as a stream of chunks, so
neither the client nor the server needs to have the whole block in one message.

The client sends the messages in the following order:
1. One header message.
2. Any number of file_data messages containing the block data in order.
3. One end message.
The block is stored only when the end message has been received. If the request stream ends without
the end message, the call fails and the block must be uploaded again.

The server streams the data forward with a single request while it is received. The block
size is limited by the maxBlockSize returned by FileUploadBegin. Blocks may be uploaded in any order and
concurrently, also to different server instances. Uploading a block again replaces it.

The data should be sent in chunks of a few megabytes at most. Each file_data message is limited by the
maximum gRPC message size of the server.

- **Service:** [Streaming file upload](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/index.md) `MFiles.IRPCFileTransferStreaming`
- **gRPC method:** `/MFiles.IRPCFileTransferStreaming/FileUploadBlock`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/file-upload-block`
- **Request:** [`FileUploadBlockRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/FileUploadBlock/index.md#request)
- **Response:** [`FileUploadBlockResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/FileUploadBlock/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: a session (mfiles-session-id-bin metadata) or a session assertion (x-mf-session-assertion metadata).
- **Idempotent:** no
- **Returns metadata structure version:** no
- **Streaming:** client

<a id="remarks"></a>

## Remarks

Begin the upload with [FileUploadBegin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadBegin/index.md) and
follow its `max_block_size` and `require_sequential_blocks`. A block index must be less than
50,000 and a block must not be empty.

<a id="request"></a>

## Request: FileUploadBlockRequest

A message of the FileUploadBlock request stream.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `header` | [`FileUploadBlockHeader`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileUploadBlockHeader/index.md) (oneof item) | The first message of the stream. Describes the block. |
| `header.file_ref` | `string` | The file_ref received from FileUploadBegin. |
| `header.block_index` | `int64` | The zero-based index of the block within the file, in content order. Must be less than 50 000. |
| `header.block_size` | `uint64` | The size of the block data in bytes. Required.<br>The data must be exactly this size and must not exceed the maxBlockSize returned by FileUploadBegin. |
| `file_data` | `bytes` (oneof item) | A chunk of the block data. |
| `end` | [`FileUploadBlockEnd`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileUploadBlockEnd/index.md) (oneof item) | The last message of the stream. Marks the block as complete. |

<a id="response"></a>

## Response: FileUploadBlockResponse

The response of the FileUploadBlock streaming method.

No fields.

<a id="related"></a>

## Related methods

- [IRPCFileTransfer.FileUploadBegin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadBegin/index.md): Begins an upload in blocks and returns its `file_ref` and the block rules.
