IRPCObjectOperations.AddObjectWithFiles
Vault API / core write session or assertion returns metadata structure version
Creates a new object, optionally with its files, and optionally checks it in.
| Service | Objects, versions, properties and files MFiles.IRPCObjectOperations |
|---|---|
| gRPC method | /MFiles.IRPCObjectOperations/AddObjectWithFiles |
| HTTP (mf-http-grpc) | POST /grpc/v1/add-object-with-files |
| Request | AddObjectWithFilesRequest |
| Response | AddObjectWithFilesResponse |
| 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 | no |
| Returns metadata structure version | yes (in the mfiles-metadata-version-bin trailer) |
| Streaming | none (unary) |
Remarks
This is the general way to create an object. One call creates the object checked out, attaches
the files, runs the creation event handlers and, if check_in is true, checks the object in. All
of it happens in one transaction: if any step fails, no object is created (the object ID
that was reserved for it is not reused).
Required properties. Send at least:
| Property definition | ID | Notes |
|---|---|---|
| Class | 100 | A lookup into value list 1 (classes). Without it: "Class was not specified." |
| Name or title | 0 | Or the property the class names as its name property (name_property_def). |
| Single file | 22 | Required for documents (object type 0) and other types that can have files. |
| Required properties of the class | is_required in the class's associated_property_defs. |
A missing required property fails with "The mandatory property value "<name>" is missing." Get the class and its required properties with GetObjectClassesAndGroups. The server fills the automatic properties (Created, Created by, Last modified, ...) itself.
Set acl. The server stores the ACL you send as the object's permissions. If acl is unset,
the object gets an empty ACL: after check-in only users with a vault-level right to see all objects
can see it, and not even its creator. To give the object ordinary permissions, send the
acl_for_objects of a named ACL from
GetNamedACLs (call it with include_builtin: true),
for example ID -1, "Full control for all internal users". For a named ACL that does not depend
on the current user, a link alone is enough:
acl { custom_component { has_named_acl: true named_acl_id: -1 } }. A link alone to the
built-in "Only for me" (-20) leaves the object without permissions; send its full
acl_for_objects, which names the user.
Single-file documents. With Single file (22) true, the object must end up with exactly one
file: true without a file source fails with "Cannot set document to single-file mode." At
check-in, the file of a single-file document takes the object's title as its file title; the
title given in the file source is not kept.
File sources (files.type and the matching files.data member):
OBJ_FILE_SOURCE_TYPE_FILE_CONTENTwithfile_content: the file bytes inline in the request. The simplest way to create a document with one file. Only for a single-file document of object type 0 (Document); otherwise the call fails with invalid argument. At most 10 MiB;titleis required.OBJ_FILE_SOURCE_TYPE_UPLOADED_FILEwithuploaded_file, orOBJ_FILE_SOURCE_TYPE_UPLOADED_FILESwithuploaded_files: content uploaded first. Give eitherupload_id(from UploadTempFile followed by UploadTempFileCommit) orfile_ref(from FileUploadWhole or FileUploadEnd, on servers that reportServerVaultCapabilities.file_upload_stateless_supported; stateless uploads are switched off by default in M-Files Server 26.11). An upload session that was not committed fails ("The process cannot access the file because it is being used by another process."), and an upload is consumed by the object it is attached to: a second object cannot use the sameupload_id.OBJ_FILE_SOURCE_TYPE_BLANK_TEMPLATE(blank_template.name) orOBJ_FILE_SOURCE_TYPE_USER_DEFINED_TEMPLATE(user_defined_template.obj_id, a template object, see GetTemplates): the file is copied from a template.OBJ_FILE_SOURCE_TYPE_EMPTY_FILESwithempty_files: files with a title and extension but no content yet. Only together withdraft: true.filesunset orOBJ_FILE_SOURCE_TYPE_UNDEFINED: no files. Set Single file (22) to false.
The response. is_visible_to_user tells whether the creator could see the new object before
it was checked in. When the checked-in object is not visible to the caller (for example because
acl was unset), created_object carries only the object ID and version number, with no
properties, files or title. Read the object again with
GetObjectInfoAndProperties when
you need its full state.
Workflow. The class's default workflow is not applied by the server when the class does not force a workflow: send Workflow (38) and Workflow State (39) yourself. A state of another workflow wins: the server sets Workflow (38) to the state's workflow. Sending only a state also sets the workflow; sending only a workflow leaves the state empty.
Permissions. The user needs the vault-level right to create objects and a license that allows modifications.
Request: AddObjectWithFilesRequest
Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page. Fields marked (recursive) refer to a type already on their path.
| Field | Type | Description |
|---|---|---|
object_type_id | int32 | The object type of the new object: 0 for documents, or the ID of another object type from GetObjectTypes. |
properties[] | repeated PropertyValue | Property values of the new object. Include Class (100), the name property (usually Name or title, 0), Single file (22) for types that can have files, and the properties the class requires. Values need no value_metadata here. |
properties[].property_def | int32 | The property definition ID, for example 0 for "Name or title" or 100 for "Class". |
properties[].value | TypedValue | The value. Its type must match the data type of the property definition. |
properties[].value.is_null_value | bool | True if the value is empty. data is then unset. |
properties[].value.type | Datatype | The data type of the value. |
properties[].value.data | TypedValueUnion | The value, in the member that matches type. Unset for an empty value. |
acl | AccessControlList | The permissions of the new object. If unset, the object gets an empty ACL and becomes invisible to its creator after check-in. Send a named ACL's acl_for_objects, or a link to a named ACL in custom_component. |
acl.checked_out_to_user | int32 | Specifies the ID of the user who has extended rights because of the checkout operation performed by her. 0 if such user does not exist. |
acl.is_fully_authoritative | bool | Specifies whether this access control list is set to ignore the secondary permissions that come from the latest checked in version. |
acl.custom_component | AccessControlListComponent | Accesses the custom component of this ACL. |
acl.custom_component.named_acl_id | int32 | Specifies the named ACL link of this component. |
acl.custom_component.has_named_acl | bool | True if the component links to a named ACL (named_acl_id). |
acl.custom_component.current_user_id | int32 | Specifies the current user binding of this component. |
acl.custom_component.has_current_user | bool | True if the component has an access control entry for the current user. |
acl.custom_component.permissions[] | repeated AccessControlEntry | The access control entry datas. The data belongs to the key in the corresponding index. |
acl.custom_component.overridability_permissions[] | repeated AccessControlEntry | Overridability permission data of this ACL component. |
acl.custom_component.status | ACCESSCONTROLLISTCOMPONENTSTATUSFLAGS | Modification status of this component. |
acl.restrictive_components[] | repeated AccessControlListComponentMapEntry | Accesses the restrictive automatic components of this ACL. |
acl.restrictive_components[].key | AccessControlListComponentKey | Access control list component. |
acl.restrictive_components[].component | AccessControlListComponent | Access control list component. |
acl.secondary_access_control_list | AccessControlList (recursive) | Secondary ACL used for latest version ACL. Not used for access check if null. |
acl.additive_components[] | repeated AccessControlListComponentMapEntry | Accesses the additive automatic components of this ACL. |
acl.additive_components[].key | AccessControlListComponentKey | Access control list component. |
acl.additive_components[].component | AccessControlListComponent | Access control list component. |
options | OBJECTOPFLAGS | Optional extra checks; for example require_read_access_after_operation makes the call fail if the caller could not see the object afterwards. |
options.all | bool | Specifies all flags set; Including any future flags. |
options.require_read_access_after_operation | bool | Requires read access to the object after the object operation. If available, the operation fails if the user does not have read access to the object after the operation. |
options.require_edit_access_after_operation | bool | Requires edit access to the object after the object operation. If available, the operation fails if the user does not have edit access to the object after the operation. |
options.disallow_name_change | bool | If specified, the operation will fail if it causes a change in the object version's name. |
options.require_change_permissions_access_after_operation | bool | Requires security change access to the object after the object operation. If available, the operation fails if the user does not have security change access to the object after the operation. |
options.require_full_access_after_operation | bool | Requires full access to the object after the object operation. If available, the operation fails if the user does not have full access to the object after the operation. |
options.change_acl_in_all_versions | bool | Changes the ACL of all versions of the object. This is currently used to request setting the ACL of all versions of an object, not just a specific version, when calling ChangeSecurity. |
options.verify_check_in_wopi_locked_document | bool | Verify the document is locked for WOPI Co-authoring or editing during checkin. |
check_in | bool | True to check the new object in. False leaves it checked out to the caller, visible only to the caller until checked in; UndoCheckout then discards the whole object. |
files | ObjFileSource | Where the files of the new object come from. Unset for an object without files. |
files.type | ObjFileSourceType | Which member of data is used. Must match the member that is set.Values: OBJ_FILE_SOURCE_TYPE_UNDEFINED (0), OBJ_FILE_SOURCE_TYPE_BLANK_TEMPLATE (1), OBJ_FILE_SOURCE_TYPE_USER_DEFINED_TEMPLATE (2), OBJ_FILE_SOURCE_TYPE_UPLOADED_FILE (3), OBJ_FILE_SOURCE_TYPE_UPLOADED_FILES (4), OBJ_FILE_SOURCE_TYPE_EMPTY_FILES (5), OBJ_FILE_SOURCE_TYPE_FILE_CONTENT (6). |
files.data | ObjFileSourceUnion | The source data; set the member that matches type. |
files.data.blank_template | ObjFileSourceUnion.BlankTemplateData (oneof data) | Blank template object file source. |
files.data.user_defined_template | ObjFileSourceUnion.UserDefinedTemplateData (oneof data) | User defined template object file source. |
files.data.uploaded_file | ObjFileSourceUnion.UploadedFileData (oneof data) | Uploaded object file source. |
files.data.uploaded_files | ObjFileSourceUnion.UploadedFilesData (oneof data) | Uploaded object file source with multiple files. |
files.data.empty_files | ObjFileSourceUnion.EmptyFilesData (oneof data) | Empty object file source (one or more files). Only the title and extension of each file are known; there is no upload id or size because the file contents have not been uploaded yet. This type may only be used when the object is created as a draft (the draft flag must be set); otherwise the request is rejected. |
files.data.file_content | ObjFileSourceUnion.FileContentData (oneof data) | Inline file content object file source. |
draft | bool | True to create the object checked out and flagged as a draft whose file content is uploaded later (used with OBJ_FILE_SOURCE_TYPE_EMPTY_FILES). Leave check_in false; clear the flag with SetObjectActive. |
Response: AddObjectWithFilesResponse
Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page. Fields marked (recursive) refer to a type already on their path.
| Field | Type | Description |
|---|---|---|
is_visible_to_user | bool | True if the caller could see the new object before check-in. It does not guarantee that created_object is complete; see the remarks. |
created_object | ObjectVersionExWP | The new object version with its properties and ACL. If the checked-in object is not visible to the caller, only its ID and version number are set. |
created_object.object_version | ObjectVersionEx | Object info. |
created_object.object_version.version_info | ObjectVersion | Object Version information. |
created_object.object_version.object_info | ObjectLevelInfo | Object-level information. |
created_object.properties[] | repeated PropertyValue | Property values, or an empty array. |
created_object.properties[].property_def | int32 | The property definition ID, for example 0 for "Name or title" or 100 for "Class". |
created_object.properties[].value | TypedValue | The value. Its type must match the data type of the property definition. |
created_object.acl | AccessControlList | If set, ACL. |
created_object.acl.checked_out_to_user | int32 | Specifies the ID of the user who has extended rights because of the checkout operation performed by her. 0 if such user does not exist. |
created_object.acl.is_fully_authoritative | bool | Specifies whether this access control list is set to ignore the secondary permissions that come from the latest checked in version. |
created_object.acl.custom_component | AccessControlListComponent | Accesses the custom component of this ACL. |
created_object.acl.restrictive_components[] | repeated AccessControlListComponentMapEntry | Accesses the restrictive automatic components of this ACL. |
created_object.acl.secondary_access_control_list | AccessControlList (recursive) | Secondary ACL used for latest version ACL. Not used for access check if null. |
created_object.acl.additive_components[] | repeated AccessControlListComponentMapEntry | Accesses the additive automatic components of this ACL. |
created_object.current_user_permissions | ObjectPermissionsForClient | If set, permissions of the object version. |
created_object.current_user_permissions.can_user_see | bool | The object is visible for the current user (provided for symmetry). |
created_object.current_user_permissions.can_user_edit | bool | The current user can edit the object. |
created_object.current_user_permissions.can_user_delete | bool | The current user can delete the object. |
created_object.current_user_permissions.can_user_change_permissions | bool | The current user can change the object permissions. |
updated_objects[] | repeated ObjectVersionEx | Information about objects that were also updated during the operation. |
updated_objects[].version_info | ObjectVersion | Object Version information. |
updated_objects[].version_info.version | ObjVerVersion | The version number, as a specific version. |
updated_objects[].version_info.display_version | string | The version label to show, if it differs from the version number; empty otherwise. |
updated_objects[].version_info.title | string | The title (name) of the object in this version. |
updated_objects[].version_info.is_single_file_object | bool | True if the object is a single-file document, which has exactly one file. |
updated_objects[].version_info.has_relationships_from_this | bool | Note: this field is deprecated. True if relationships from this object version to one or more documents exist. |
updated_objects[].version_info.has_relationships_to_this | bool | Note: this field is deprecated. True if relationships from one or more documents to this object version exist. |
updated_objects[].version_info.has_assignments | bool | True if relationships from one or more assignments to this object version exist. |
updated_objects[].version_info.last_modified_at_utc | google.protobuf.Timestamp | When the version was last modified, in UTC. |
updated_objects[].version_info.files[] | repeated File | The files of this version. Each file_ver can be passed to DownloadFile_Begin. |
updated_objects[].version_info.object_version_flags | OBJVERFLAGS | Bit flags that provide additional information on the object version. |
updated_objects[].version_info.class_id | int32 | The class ID of the version. |
updated_objects[].version_info.version_guid | string | The GUID of this version. |
updated_objects[].version_info.base_properties[] | repeated PropertyValue | Not filled by the object read methods; read the property values with GetObjectVersionAndPropertiesOfMultipleObjects or GetProperties. |
updated_objects[].version_info.primary_file | FileID | File ID of the primary file of a multi-file object, if the object is a multi-file object. |
updated_objects[].object_info | ObjectLevelInfo | Object-level information. |
updated_objects[].object_info.obj_id | ObjID | The object type and ID of the object. |
updated_objects[].object_info.external_id_status | ExtIDStatus | The 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_id | string | The 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_version | ObjVerVersion | The version that is checked out. Version number 0 if the object is not checked out. |
updated_objects[].object_info.checked_out_to_user_id | int32 | The ID of the user who has the object checked out. |
updated_objects[].object_info.checked_out_to_user_name | string | The user name of the user who has the object checked out. |
updated_objects[].object_info.checked_out_to_host_name | string | The host name of the computer to which the object was checked out. |
updated_objects[].object_info.checked_out_at_utc | google.protobuf.Timestamp | The timestamp of the moment the object was checked out. |
updated_objects[].object_info.checked_in_version | ObjVerVersion | The latest checked-in version. |
updated_objects[].object_info.created_at_utc | google.protobuf.Timestamp | The time when the object was created (same as the PROPERTYDEF_CREATED propertyvalue). |
updated_objects[].object_info.accessed_by_me_utc | google.protobuf.Timestamp | Accessed 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.guid | string | The object GUID, in braces. The same value as GetObjectGUID returns. |
updated_objects[].object_info.options | ITEMFLAGS | Bit flags that provide additional information on the object (e.g. is the object deleted or a stub). |
updated_objects[].object_info.original_vault_guid | string | The GUID of the vault in which the object was originally created. |
updated_objects[].object_info.original_vault_obj_id | ObjID | The original objid in the vault in which the object was originally created. |
updated_objects[].object_info.associated_view_id | ItemID | Identifies the view associated with this object if any. |
updated_objects[].object_info.external_repository_icon_id | string | If not null, identifies the icon of the object. Currently applicable only to unmanaged objects. |
updated_objects[].object_info.primary_view_id | ItemID | If 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.capabilities | OBJECTCAPABILITYFLAGS | Bit flags that provide information on the object capabilities. |
Related methods
- IRPCPropertyDefs.GetObjectClassesAndGroups -- Gets all classes and class groups that the user is allowed to see.
- IRPCNamedACLs.GetNamedACLs -- Gets the named ACLs of the given types that the calling user is allowed to see.
- UploadTempFile -- 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.
- UploadTempFileCommit -- Completes an upload made with UploadTempFile.
- IRPCFileTransferStreaming.FileUploadWhole -- Uploads a whole file by streaming its content.
- IRPCFileTransfer.FileUploadEnd -- Completes an upload in blocks. Binds the content to no object; use FileUploadAttach or AddObjectWithFiles for that.
- GetTemplates -- Gets the templates of an object type, optionally only those of one class or matching keywords.
- GetObjectInfoAndProperties -- Gets the version information and the property values of one object, either its latest version or a specific version.
- AddObject -- Creates a new object without files.
- AddObjectWithFilesWithPropertyMetadata -- Creates a new object with files, storing metadata about each property value (who or what set it, why, and with what confidence).