Document new version¶
Lifecycle Twin API doesn't have a logic to create a new version automatically for the file with the same name. API provides the method to check if the new version must be created or not.
Normally the process to create a new version requires 2 steps:
- Check if the document with the same file name already exist
- Upload the new file to the existing document
Check if document exist¶
Use the standard GET query with the relevant filter
GET /{entityName}/tabs
Header | Value |
---|---|
filter | {"equals":{"Files.Name":"Screenshot 2022-12-20 180429.png"}} |
Output example:
[
{
"Name": "Screenshot 2022-12-20 180429.png1",
"Files": [
{
"Name": "Screenshot 2022-12-20 180429.png",
"Size": 0,
"SourceType": 0,
"CreatedOn": "0001-01-01T00:00:00Z",
"Version": 0,
"TotalFileParts": 0,
"FilePart": 0,
"Id": "9eae91b1-0c89-8777-5d70-dcc238af074e"
}
],
"Version": 0,
"Parent": {
"Name": "RME_basic_sample_project",
"Version": 0,
"IsFolder": false,
"SubFoldersCount": 0,
"ChildrenCount": 0,
"IsAutoName": false,
"CheckedOut": false,
"Id": "2320efac-0214-49ad-ae5d-a1a99eb5b6c6"
},
"Id": "9c5dc8bd-57c9-4196-adc6-9ec2369df975"
}
]
Upload new version¶
PUT /documents/{documentId}/upload
Header | Value |
---|---|
select | {"Files": {"Id", "ContentType"}, "Version"} |
Body - Multipart
First part:
{
"Id": "{documentId}",
"Files": [
{
"Name": "Screenshot 2022-12-20 180429.png",
"ContentType": "image/png",
"FilePart": 1
}
]
}
Second part - file stream
Note
- Files.Name must be exactly the same as the name of the file in the document. Otherwise the new version will not be created
- ContentType is mandatory and defined by the host application
- FilePart is mandatory and equals 1