# IRPCScanningAndOCR.OCROperation_BeginAfterUpload

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

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

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

Starts an OCR job on a file that the caller uploaded with UploadTempFile.

- **Service:** [Scanning and OCR](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/index.md) `MFiles.IRPCScanningAndOCR`
- **gRPC method:** `/MFiles.IRPCScanningAndOCR/OCROperation_BeginAfterUpload`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/ocroperation_-begin-after-upload`
- **Request:** [`OCROperation_BeginAfterUploadRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_BeginAfterUpload/index.md#request)
- **Response:** [`OCROperation_BeginAfterUploadResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_BeginAfterUpload/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **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

- Upload the file with [UploadTempFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFile/index.md) and
  pass its `upload_id` and size here. **Do not commit the upload** with
  [UploadTempFileCommit](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFileCommit/index.md): this call
  commits it itself, and an upload that is already committed fails with "File size mismatch.".
- The upload is consumed, also when the call fails.
- Fails with "OCR feature is disabled by license or settings." when server OCR is not
  available.
- Returns at once; poll [OCROperation_Status](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Status/index.md)
  and finish with
  [OCROperation_EndWithDownload](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_EndWithDownload/index.md).

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

## Request: OCROperation_BeginAfterUploadRequest

> 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 |
|---|---|---|
| `type` | [`OCROperationType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.OCROperationType/index.md) | What to produce. See the service overview. Values: `OCROPERATION_TYPE_NONE` (0), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_PDF` (1), `OCROPERATION_TYPE_RECOGNIZE_SPECIFIC_BLOCKS` (2), `OCROPERATION_TYPE_RECOGNIZE_ANY_BLOCKS` (3), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_PDF_AND_RECOGNIZE_SPECIFIC_BLOCKS` (4), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_PDF_AND_RECOGNIZE_ANY_BLOCKS` (5), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_ARCHIVE_PDF` (6), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_ARCHIVE_PDF_AND_RECOGNIZE_SPECIFIC_BLOCKS` (7), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_ARCHIVE_PDF_AND_RECOGNIZE_ANY_BLOCKS` (8). |
| `options` | [`OCROptions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCROptions/index.md) | Recognition languages and automatic language detection. Unset uses the defaults. |
| `options.languages[]` | repeated [`OCRLanguageType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.OCRLanguageType/index.md) | Languages/character sets/dictionaries to be used as recognition hints. Can be unset. |
| `options.ocr_automatic_language_detection` | `bool` | True if the OCR automatic language detection is to be used. |
| `upload_session` | `int32` | The `upload_id` of an uploaded, not committed file. |
| `upload_file_size` | `int64` | The size of the uploaded file in bytes; must match the uploaded bytes. |
| `source_file_extension` | `string` | The file name extension of the uploaded file, without the dot, for example `pdf` or `tif`. |
| `pages` | [`OCRPageArray`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRPageArray/index.md) | For `..._RECOGNIZE_SPECIFIC_BLOCKS` types, the areas to recognize, per page. Otherwise leave unset. |
| `pages.value[]` | repeated [`OCRPage`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRPage/index.md) | An array of OCR pages, should be ordered by the page number. |
| `pages.value[].number` | `uint32` | Page number of this page. |
| `pages.value[].blocks[]` | repeated [`OCRBlock`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRBlock/index.md) | An array of OCR blocks. |

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

## Response: OCROperation_BeginAfterUploadResponse

> 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 |
|---|---|---|
| `background_op_id` | `uint32` | The ID of the job. |

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

## Related methods

- [IRPCObjectOperations.UploadTempFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFile/index.md): Uploads a block of a file to a temporary upload session on the server. The upload can then be used as the content of a new object.
- [IRPCObjectOperations.UploadTempFileCommit](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/UploadTempFileCommit/index.md): Completes an upload made with UploadTempFile.
- [OCROperation_Status](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Status/index.md): Gets the progress of an OCR job, and optionally cancels it.
- [OCROperation_EndWithDownload](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_EndWithDownload/index.md): Ends an OCR job and returns its results: the recognized texts and a download of the PDF.
- [OCROperation_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Begin/index.md): Starts an OCR job on a file of a document that the caller has checked out.
- [OCROperation_End](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_End/index.md): Ends an OCR job started with OCROperation_Begin and replaces the document's file with the resulting PDF.
