IRPCObjectOperations.DownloadFile_Begin

View as Markdown

Vault API / core read session or assertion idempotent returns metadata structure version

Opens a download session for a file version and returns its ID, the content size and, on request, its MD5 checksum.

ServiceObjects, versions, properties and files MFiles.IRPCObjectOperations
gRPC method/MFiles.IRPCObjectOperations/DownloadFile_Begin
HTTP (mf-http-grpc)POST /grpc/v1/download-file_-begin
RequestDownloadFile_BeginRequest
ResponseDownloadFile_BeginResponse
Book and levelVault API, core
Kindread
SessionRequired: a session (mfiles-session-id-bin metadata) or a session assertion (x-mf-session-assertion metadata).
Idempotentyes
Returns metadata structure versionyes (in the mfiles-metadata-version-bin trailer)
Streamingnone (unary)

Remarks

Downloading a file takes three calls:

  1. DownloadFile_Begin with the file's obj_file_ver and prepare_file_for_downloading true.
  2. DownloadFile_ReadBlock with the returned download_id, from offset 0, until a block shorter than requested comes back. Blocks are at most 4 MiB.
  3. DownloadFile_Stop. When the whole file was read in order from the start, the server has already closed the session; the call still succeeds, so always make it.

Take obj_file_ver.file_ver from the version information of the object (File file_ver). It must be a specific file version: FILE_VER_TYPE_LATEST fails with "Not found. (File <id>-0 not found.)".

Formats. FILE_FORMAT_NATIVE downloads the file as stored. FILE_FORMAT_PDF and FILE_FORMAT_DISPLAY_ONLY_PDF download a PDF rendition that the server creates if needed (for example from Office files); file_outline.size is then the size of the PDF. FILE_FORMAT_PLAIN_TEXT and FILE_FORMAT_MARKDOWN are not supported here ("The requested file format ... is not supported."); use GetTextContentForFileWithFormat.

Checksum. file_outline.md5_checksum is filled only when need_checksum is true; otherwise it is 32 zeros. For the PDF formats the server currently returns the checksum of the native file, not of the PDF, so do not verify a PDF download against it.

Session. A download session belongs to the login session that opened it, on the server that opened it. An unused session is closed after about 10 minutes (server default).

Request: DownloadFile_BeginRequest

Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

FieldTypeDescription
obj_file_verObjFileVerThe object and the specific file version, as in File.file_ver.
obj_file_ver.obj_idObjIDThe object that owns the file.
obj_file_ver.obj_id.typeint32The object type ID, for example 0 for documents. In a lookup value, the value list ID (for a lookup to objects, the object type ID).
obj_file_ver.obj_id.item_idItemIDThe ID of the object within its type, in item_id.internal_id.
obj_file_ver.file_verFileVerThe specific file version, as in File.file_ver.
obj_file_ver.file_ver.file_idFileIDThe file.
obj_file_ver.file_ver.typeFileVerTypeFILE_VER_TYPE_SPECIFIC for a file version number.Values: FILE_VER_TYPE_UNINITIALIZED (0), FILE_VER_TYPE_LATEST (1), FILE_VER_TYPE_ANY (2), FILE_VER_TYPE_SPECIFIC (3).
obj_file_ver.file_ver.internal_versionint32The file version number.
obj_file_ver.file_ver.external_repository_versionstringUsed only for files in external repositories. Leave empty.
obj_file_ver.file_ver.external_repository_sort_keyint64Used only for files in external repositories. Leave 0.
formatFileFormatFILE_FORMAT_NATIVE (default), FILE_FORMAT_PDF or FILE_FORMAT_DISPLAY_ONLY_PDF.Values: FILE_FORMAT_NATIVE (0), FILE_FORMAT_PDF (1), FILE_FORMAT_DISPLAY_ONLY_PDF (2), FILE_FORMAT_PLAIN_TEXT (3), FILE_FORMAT_MARKDOWN (4).
prepare_file_for_downloadingboolMust be true to download. False only checks the caller's access and records the file as accessed; download_id is then 0.
need_checksumboolTrue to get the MD5 checksum of the native file in file_outline.md5_checksum.

Response: DownloadFile_BeginResponse

Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

FieldTypeDescription
download_idint32The download session for DownloadFile_ReadBlock and DownloadFile_Stop. 0 if prepare_file_for_downloading was false.
file_outlineFileOutlineThe size of the content to download, in the requested format, and the checksum if requested.
file_outline.sizeint64The size of the content in bytes, in the downloaded format.
file_outline.size_precisionFileSizePrecisionThe file size precision. If the file size precision is 'exact', the size can be used for reading the file content. If the precision is 'unknown', the size field should not be used at all.Values: FILE_SIZE_PRECISION_EXACT (0), FILE_SIZE_PRECISION_ESTIMATE (1), FILE_SIZE_PRECISION_UNKNOWN (2).
file_outline.md5_checksumstringThe MD5 checksum as 32 hexadecimal digits, if requested; 32 zeros otherwise.
ov_exObjectVersionExThe version information of the object that owns the file.
ov_ex.version_infoObjectVersionObject Version information.
ov_ex.version_info.versionObjVerVersionThe version number, as a specific version.
ov_ex.version_info.display_versionstringThe version label to show, if it differs from the version number; empty otherwise.
ov_ex.version_info.titlestringThe title (name) of the object in this version.
ov_ex.version_info.is_single_file_objectboolTrue if the object is a single-file document, which has exactly one file.
ov_ex.version_info.has_relationships_from_thisboolNote: this field is deprecated. True if relationships from this object version to one or more documents exist.
ov_ex.version_info.has_relationships_to_thisboolNote: this field is deprecated. True if relationships from one or more documents to this object version exist.
ov_ex.version_info.has_assignmentsboolTrue if relationships from one or more assignments to this object version exist.
ov_ex.version_info.last_modified_at_utcgoogle.protobuf.TimestampWhen the version was last modified, in UTC.
ov_ex.version_info.files[]repeated FileThe files of this version. Each file_ver can be passed to DownloadFile_Begin.
ov_ex.version_info.object_version_flagsOBJVERFLAGSBit flags that provide additional information on the object version.
ov_ex.version_info.class_idint32The class ID of the version.
ov_ex.version_info.version_guidstringThe GUID of this version.
ov_ex.version_info.base_properties[]repeated PropertyValueNot filled by the object read methods; read the property values with GetObjectVersionAndPropertiesOfMultipleObjects or GetProperties.
ov_ex.version_info.primary_fileFileIDFile ID of the primary file of a multi-file object, if the object is a multi-file object.
ov_ex.object_infoObjectLevelInfoObject-level information.
ov_ex.object_info.obj_idObjIDThe object type and ID of the object.
ov_ex.object_info.external_id_statusExtIDStatusThe status of this object's external ID.Values: EXT_IDSTATUS_UNKNOWN (0), EXT_IDSTATUS_EXTERNAL (1), EXT_IDSTATUS_INTERNAL (2), EXT_IDSTATUS_DISCARDED (3), EXT_IDSTATUS_NOT_AVAILABLE (4), EXT_IDSTATUS_EXTERNAL_REDUCED (5).
ov_ex.object_info.external_idstringThe external ID (display ID) of this object. unset means that the external ID is the same as the internal ID.
ov_ex.object_info.checked_out_versionObjVerVersionThe version that is checked out. Version number 0 if the object is not checked out.
ov_ex.object_info.checked_out_to_user_idint32The ID of the user who has the object checked out.
ov_ex.object_info.checked_out_to_user_namestringThe user name of the user who has the object checked out.
ov_ex.object_info.checked_out_to_host_namestringThe host name of the computer to which the object was checked out.
ov_ex.object_info.checked_out_at_utcgoogle.protobuf.TimestampThe timestamp of the moment the object was checked out.
ov_ex.object_info.checked_in_versionObjVerVersionThe latest checked-in version.
ov_ex.object_info.created_at_utcgoogle.protobuf.TimestampThe time when the object was created (same as the PROPERTYDEF_CREATED propertyvalue).
ov_ex.object_info.accessed_by_me_utcgoogle.protobuf.TimestampAccessed by me timestamp. Parallel operations may cause slight inconsistencies in the returned timestamp in rare cases and the precise value shouldn't be relied upon. The observed timestamp may even roll back.
ov_ex.object_info.guidstringThe object GUID, in braces. The same value as GetObjectGUID returns.
ov_ex.object_info.optionsITEMFLAGSBit flags that provide additional information on the object (e.g. is the object deleted or a stub).
ov_ex.object_info.original_vault_guidstringThe GUID of the vault in which the object was originally created.
ov_ex.object_info.original_vault_obj_idObjIDThe original objid in the vault in which the object was originally created.
ov_ex.object_info.associated_view_idItemIDIdentifies the view associated with this object if any.
ov_ex.object_info.external_repository_icon_idstringIf not null, identifies the icon of the object. Currently applicable only to unmanaged objects.
ov_ex.object_info.primary_view_idItemIDIf not null, identifies the primary view of the object that is also the default opening location of the object. Currently applicable only to unmanaged objects.
ov_ex.object_info.capabilitiesOBJECTCAPABILITYFLAGSBit flags that provide information on the object capabilities.
updated_objects[]repeated ObjectVersionExInformation about objects that were also updated during the operation. (represented by ObjectVersionEx structs.)
updated_objects[].version_infoObjectVersionObject Version information.
updated_objects[].version_info.versionObjVerVersionThe version number, as a specific version.
updated_objects[].version_info.display_versionstringThe version label to show, if it differs from the version number; empty otherwise.
updated_objects[].version_info.titlestringThe title (name) of the object in this version.
updated_objects[].version_info.is_single_file_objectboolTrue if the object is a single-file document, which has exactly one file.
updated_objects[].version_info.has_relationships_from_thisboolNote: this field is deprecated. True if relationships from this object version to one or more documents exist.
updated_objects[].version_info.has_relationships_to_thisboolNote: this field is deprecated. True if relationships from one or more documents to this object version exist.
updated_objects[].version_info.has_assignmentsboolTrue if relationships from one or more assignments to this object version exist.
updated_objects[].version_info.last_modified_at_utcgoogle.protobuf.TimestampWhen the version was last modified, in UTC.
updated_objects[].version_info.files[]repeated FileThe files of this version. Each file_ver can be passed to DownloadFile_Begin.
updated_objects[].version_info.object_version_flagsOBJVERFLAGSBit flags that provide additional information on the object version.
updated_objects[].version_info.class_idint32The class ID of the version.
updated_objects[].version_info.version_guidstringThe GUID of this version.
updated_objects[].version_info.base_properties[]repeated PropertyValueNot filled by the object read methods; read the property values with GetObjectVersionAndPropertiesOfMultipleObjects or GetProperties.
updated_objects[].version_info.primary_fileFileIDFile ID of the primary file of a multi-file object, if the object is a multi-file object.
updated_objects[].object_infoObjectLevelInfoObject-level information.
updated_objects[].object_info.obj_idObjIDThe object type and ID of the object.
updated_objects[].object_info.external_id_statusExtIDStatusThe status of this object's external ID.Values: EXT_IDSTATUS_UNKNOWN (0), EXT_IDSTATUS_EXTERNAL (1), EXT_IDSTATUS_INTERNAL (2), EXT_IDSTATUS_DISCARDED (3), EXT_IDSTATUS_NOT_AVAILABLE (4), EXT_IDSTATUS_EXTERNAL_REDUCED (5).
updated_objects[].object_info.external_idstringThe external ID (display ID) of this object. unset means that the external ID is the same as the internal ID.
updated_objects[].object_info.checked_out_versionObjVerVersionThe version that is checked out. Version number 0 if the object is not checked out.
updated_objects[].object_info.checked_out_to_user_idint32The ID of the user who has the object checked out.
updated_objects[].object_info.checked_out_to_user_namestringThe user name of the user who has the object checked out.
updated_objects[].object_info.checked_out_to_host_namestringThe host name of the computer to which the object was checked out.
updated_objects[].object_info.checked_out_at_utcgoogle.protobuf.TimestampThe timestamp of the moment the object was checked out.
updated_objects[].object_info.checked_in_versionObjVerVersionThe latest checked-in version.
updated_objects[].object_info.created_at_utcgoogle.protobuf.TimestampThe time when the object was created (same as the PROPERTYDEF_CREATED propertyvalue).
updated_objects[].object_info.accessed_by_me_utcgoogle.protobuf.TimestampAccessed by me timestamp. Parallel operations may cause slight inconsistencies in the returned timestamp in rare cases and the precise value shouldn't be relied upon. The observed timestamp may even roll back.
updated_objects[].object_info.guidstringThe object GUID, in braces. The same value as GetObjectGUID returns.
updated_objects[].object_info.optionsITEMFLAGSBit flags that provide additional information on the object (e.g. is the object deleted or a stub).
updated_objects[].object_info.original_vault_guidstringThe GUID of the vault in which the object was originally created.
updated_objects[].object_info.original_vault_obj_idObjIDThe original objid in the vault in which the object was originally created.
updated_objects[].object_info.associated_view_idItemIDIdentifies the view associated with this object if any.
updated_objects[].object_info.external_repository_icon_idstringIf not null, identifies the icon of the object. Currently applicable only to unmanaged objects.
updated_objects[].object_info.primary_view_idItemIDIf not null, identifies the primary view of the object that is also the default opening location of the object. Currently applicable only to unmanaged objects.
updated_objects[].object_info.capabilitiesOBJECTCAPABILITYFLAGSBit flags that provide information on the object capabilities.