# IRPCTest.DownloadTestFile_Begin

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) > [Connection and health checks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCTest/index.md)

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

Badges: `Vault API / standard` `read` `session` `idempotent` `returns metadata structure version`

Creates a file of random bytes on the server and opens a download session for it, for measuring
download throughput.

- **Service:** [Connection and health checks](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCTest/index.md) `MFiles.IRPCTest`
- **gRPC method:** `/MFiles.IRPCTest/DownloadTestFile_Begin`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/download-test-file_-begin`
- **Request:** [`DownloadTestFile_BeginRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCTest/DownloadTestFile_Begin/index.md#request)
- **Response:** [`DownloadTestFile_BeginResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCTest/DownloadTestFile_Begin/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** read
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** yes
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

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

## Remarks

Needs a vault session. Without a session the call fails with `UNAUTHENTICATED`; a server-level
session fails with `E_MFILES_LOGIN_REQUIRED`. `file_size` must be from 0 to 52428800 (50 MiB);
other values fail with `E_INVALIDARG` ("The parameter is incorrect.").

The server writes `file_size` random bytes to a temporary file of the vault; the content differs
on every call and does not compress. Read it like any other download:

1. Call this method and keep `download_id`.
2. Read the blocks with
   [DownloadFile_ReadBlock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock/index.md), at most
   4 MiB per call, and time those calls. Creating the file is part of this method, not of the
   reads (on a local server, `DownloadTestFile_Begin` for 50 MiB took about 200 ms).
3. Close the session with
   [DownloadFile_Stop](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Stop/index.md). When the file was read
   in order and the last read returned fewer bytes than requested, the server has already closed
   the session; `DownloadFile_Stop` still succeeds.

The response carries only `download_id`.

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

## Request: DownloadTestFile_BeginRequest

> 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 |
|---|---|---|
| `file_size` | `int64` | The size of the test file in bytes, 0 to 52428800 (50 MiB). |

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

## Response: DownloadTestFile_BeginResponse

> 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` | The download session for `DownloadFile_ReadBlock` and `DownloadFile_Stop`. Valid only with the session that started it. |

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

## Related methods

- [IRPCObjectOperations.DownloadFile_ReadBlock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock/index.md): Reads a block of a file from a download session.
- [IRPCObjectOperations.DownloadFile_Stop](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Stop/index.md): Closes a download session.
