# Stateless file upload sessions (IRPCFileTransfer)

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)

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

Stateless file upload. No method requires a sticky session.

The file_ref identifies state in Master Storage, not in an MFServer process, so any server instance
can serve any call.

The file data is sent with the hand-written client-streaming methods of IRPCFileTransferStreaming in
mfiles.filestreaming.proto, as the IDL supports only unary methods:
- FileUploadWhole: uploads a whole file in one call.
- FileUploadBlock: uploads one block between FileUploadBegin and FileUploadEnd.

- **gRPC service:** `MFiles.IRPCFileTransfer`
- **Book and level:** [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md), standard
- **Methods:** 3
- **Proto file:** [`mfiles/IRPCFileTransfer.proto`](https://developer.m-files.com/APIs/gRPC-API/downloads/proto/mfiles/IRPCFileTransfer.proto)

<a id="overview"></a>

## Overview

Uploads identified by a `file_ref` string instead of an upload ID. Together with
[IRPCFileTransferStreaming](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/index.md), which carries the data,
this service is an alternative to the upload sessions of
[UploadTempFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFile/index.md) and
[UploadFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadFile/index.md).

**Availability.** Stateless uploads are switched off by default in M-Files Server 26.11: every
method of this service and of `IRPCFileTransferStreaming` then answers "Not implemented.", and
[ServerVaultCapabilities](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ServerVaultCapabilities/index.md)
`file_upload_stateless_supported` is false. Check that capability first; when it is false, upload
with [UploadTempFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFile/index.md) and
[UploadTempFileCommit](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFileCommit/index.md) instead. See
[Files](https://developer.m-files.com/APIs/gRPC-API/runtime/files/index.md).

**Two ways to upload.**

- A file that fits in one storage request (see the size limit of `FileUploadWhole`):
  [FileUploadWhole](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/FileUploadWhole/index.md), one call.
- Any file: [FileUploadBegin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadBegin/index.md),
  [FileUploadBlock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransferStreaming/FileUploadBlock/index.md) for each block, then
  [FileUploadEnd](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadEnd/index.md).

**Using the upload.** An ended upload is used by its `file_ref`: as the content of an existing file
of a checked-out object with [FileUploadAttach](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadAttach/index.md),
in the `file_ref` field of the uploaded-file sources of
[AddObjectWithFiles](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/AddObjectWithFiles/index.md), with
[DownloadTempFileFromUpload_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadTempFileFromUpload_Begin/index.md),
and as OCR input in [IRPCScanningAndOCR](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/index.md).

**Where the upload is stored.** This depends on where the vault keeps its file data, and decides
what `FileUploadBegin` returns:

| Vault file data | `file_ref` | Blocks | Served by |
| --- | --- | --- | --- |
| Master Storage | a GUID | up to the Master Storage single request limit, any order | any server instance |
| Azure Blob Storage | a GUID | up to the Blob Storage block size (4 MiB by default), any order | any server instance |
| Disk or database | the upload ID in decimal | up to 4 MiB, in order | the server and login session that began it |

In the last case the upload is an upload session as with `UploadTempFile`: it is bound to the
login session and the server instance, and anonymous sessions cannot upload.

<a id="methods"></a>

## Methods

| Method | Summary | Facts |
|---|---|---|
| [FileUploadAttach](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadAttach/index.md) | Stores an ended upload as the new content of an existing file of an object that is checked out to the caller. | `write` `session or assertion` `returns metadata structure version` |
| [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. | `write` `session or assertion` |
| [FileUploadEnd](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCFileTransfer/FileUploadEnd/index.md) | Completes an upload in blocks. Binds the content to no object; use FileUploadAttach or AddObjectWithFiles for that. | `write` `session or assertion` |
