IRPCObjectOperations.UploadTempFile
Vault API / core write session or assertion idempotent
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.
| Service | Objects, versions, properties and files MFiles.IRPCObjectOperations |
|---|---|
| gRPC method | /MFiles.IRPCObjectOperations/UploadTempFile |
| HTTP (mf-http-grpc) | POST /grpc/v1/upload-temp-file |
| Request | UploadTempFileRequest |
| Response | UploadTempFileResponse |
| Book and level | Vault API, core |
| Kind | write |
| 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) |
Remarks
Upload a file in one or more calls:
- The first call has
upload_id0,offset0 and thetotal_size_in_bytesof the file. It returns the newupload_id. - Further calls pass that
upload_idand theoffsetof their block. - UploadTempFileCommit completes the upload.
The committed upload can be used by
AddObjectWithFiles (files with
OBJ_FILE_SOURCE_TYPE_UPLOADED_FILE or ..._UPLOADED_FILES and the upload_id), which consumes
it, and by DownloadTempFileFromUpload_Begin
and GetTextContentForTemporaryFile.
An upload that is not committed cannot be used ("The process cannot access the file because it is
being used by another process.").
Session. The upload belongs to the calling login session, on the server that received the
first block; another login session gets "Not found. (The specified upload session <id> does not
exist.)". An upload that is not used for about 10 minutes (server default) is removed: call
KeepUploadSessionAlive at the interval
given in SessionData.keep_upload_session_alive_interval_in_seconds if you keep it longer.
Remove uploads you do not use with
RemoveUploadSession. Anonymous sessions
cannot upload.
Each request is limited by the server's maximum gRPC message size (48 MiB by default).
Request: UploadTempFileRequest
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 |
|---|---|---|
upload_id | int32 | 0 to start a new upload; the returned ID for the following blocks. |
total_size_in_bytes | int64 | The size of the whole file. Read only in the first call. |
offset | int64 | The position of this block in the file. Must be 0 in the first call. Use multiples of 4096 bytes for all blocks but the last. |
data | bytes | The bytes of this block. |
temp_extension | StringValue | The file name extension of the upload, without the dot (for example "pdf"). Set it in the first call. DownloadTempFileFromUpload_Begin returns it as file_extension. |
temp_extension.value | string | String. |
Response: UploadTempFileResponse
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 |
|---|---|---|
upload_id | int32 | The ID of the upload. |
Related methods
- UploadTempFileCommit -- Completes an upload made with UploadTempFile.
- AddObjectWithFiles -- Creates a new object, optionally with its files, and optionally checks it in.
- DownloadTempFileFromUpload_Begin -- Opens a download session for a committed upload, to read it back or as a PDF, without creating an object.
- GetTextContentForTemporaryFile -- Gets the plain text content of a file uploaded with UploadTempFile.
- KeepUploadSessionAlive -- Keeps an upload from being removed for inactivity.
- RemoveUploadSession -- Removes an upload and its temporary file.