# IRPCObjectOperations.DownloadFile_ReadBlock

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) > [Objects, versions, properties and files](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/index.md)

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

Badges: `Vault API / core` `read` `session or assertion` `idempotent`

Reads a block of a file from a download session.

- **Service:** [Objects, versions, properties and files](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/index.md) `MFiles.IRPCObjectOperations`
- **gRPC method:** `/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/download-file_-read-block`
- **Request:** [`DownloadFile_ReadBlockRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock/index.md#request)
- **Response:** [`DownloadFile_ReadBlockResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock/index.md#response)
- **Book and level:** Vault API, core
- **Kind:** read
- **Session:** Required: a session (mfiles-session-id-bin metadata) or a session assertion (x-mf-session-assertion metadata).
- **Idempotent:** yes
- **Returns metadata structure version:** no
- **Streaming:** none (unary)

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

## Remarks

`block_size` is at most 4 MiB (4194304 bytes); a larger value fails with "The parameter is
incorrect. (Block size exceeded the limit of 4194304 bytes.)". The server returns `block_size`
bytes, or fewer at the end of the file; an `offset` at or past the end returns no data. Blocks can
be read in any order and read again.

When the last block has been read and the file was read in order from offset 0, the server
closes the download session; a later read fails with "Not found. (The specified download session
<id> does not exist.)". Otherwise close it with
[DownloadFile_Stop](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Stop/index.md).

The session also serves the downloads opened by
[DownloadTempFileFromUpload_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadTempFileFromUpload_Begin/index.md).

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

## Request: DownloadFile_ReadBlockRequest

> 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 |
|---|---|---|
| `download_id` | `int32` | From `DownloadFile_Begin` or `DownloadTempFileFromUpload_Begin`. |
| `block_size` | `uint32` | The number of bytes to read, at most 4194304 (4 MiB). |
| `offset` | `int64` | The byte offset to read from. |

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

## Response: DownloadFile_ReadBlockResponse

> 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 |
|---|---|---|
| `data` | `bytes` | The bytes read. Shorter than `block_size` at the end of the file; empty past the end. |

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

## Related methods

- [DownloadFile_Stop](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Stop/index.md): Closes a download session.
- [DownloadTempFileFromUpload_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadTempFileFromUpload_Begin/index.md): Opens a download session for a committed upload, to read it back or as a PDF, without creating an object.
- [DownloadFile_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Begin/index.md): Opens a download session for a file version and returns its ID, the content size and, on request, its MD5 checksum.
- [DownloadFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile/index.md): Not available over native gRPC: the server answers "Not implemented.". Used by the M-Files HTTP gateway.
