Skip to main content

Create new file from revision

Заметка

[Since 20217.02]

A request to create a new file based on specified revision.

POST /api/v1/files/{fileId}/revisions/{revId}/newFile
  1. Path parameters
ParameterDescription
fileIdId of a file
revIdId of a revision
  1. Request parameters
ParameterDescription
folderIdTarget folder id
conflictStrategyConflict resolution strategy (keep_both / overwrite / versioned)
filenameFilename for created file
timezoneOffsetMinsTimezone to be used during the conversion process. [Since 2017.03] (For prerender regeneration)
  1. Response structure
PathTypeDescription
fileObjectFile object metadata
linksArrayArray of links to file object. See File Links
file.idStringThe ID of the file
file.filenameStringThe name of the file
file.mediaTypeStringThe media type of the file
file.createdDateDateCreate time for this file (formatted ISO8601 timestamp)
file.fileSizeNumberThe size of the file in bytes
file.lastModifyingUserIdStringThe ID of the user who last modified the file
file.lastModifyingUserFsIdStringThe FS ID of the user who last modified the file
file.lastModifyingUserFirstNameStringThe first name of the user who last modified the file
file.lastModifyingUserMiddleNameStringThe middle name of the user who last modified the file
file.lastModifyingUserLastNameStringThe last name of the user who last modified the file
file.modifiedByMeDateDateLast time this file was modified by the user (formatted RFC 3339 timestamp)
file.autoCreationRevisionsBooleanShould new version of file be created automatically during collaboration
file.lastViewedByMeDateDateLast time this file was viewed by the user (formatted RFC 3339 timestamp)
file.sharedWithMeDateDateTime at which this file was shared with the user (formatted RFC 3339 timestamp)
file.modifiedDateDateLast time this file was modified by anyone (formatted RFC 3339 timestamp)
file.parentIdStringThe parent folder (parentReferenceId) which contains this file. The root has no parent
file.creatorStringThe original creator (userId) of this file
file.creatorFsIdStringThe FS ID of the user who create the file
file.creatorFirstNameStringThe first name of the user who create the file
file.creatorMiddleNameStringThe middle name of the user who create the file
file.creatorLastNameStringThe last name of the user who create the file
file.propertiesArrayThe list of file’s properties
file.checksumStringAn MD5 checksum for the content of this file
file.headRevisionIdStringThe ID of the file’s head (last) revision
file.isVersionBooleanThe file is version or not
file.prerenderStringThe id of prerendered file
file.previewStringThe id of preview file
file.previewFailureMarkDateFlag to show unix time of unsuccessful preview generation
file.prerenderFailureMarkDateFlag to show unix time of unsuccessful prerender generation
file.thumbnailFailureMarkDateFlag to show unix time of unsuccessful thumbnail generation
file.ownerIdStringThe owner (userId) of this file
file.etagStringETag (HTTP Entity Tag) of the file
file.ownerFsIdStringThe owner (userId) of this file
file.publicLinkIdStringPublic link id. [Since 2021.03]
file.treeStringAbsolute path to this file for current user. Set of parent’s names and name of the file
file.ownerFirstNameStringThe owner first name of this file
file.ownerLastNameStringThe owner last name of this file
file.ownerMiddleNameStringThe owner middle name of this file
file.totalSizeNumberTotal size of all file’s versions
file.currentRevisionObjectObjectCurrent revision object. See Get file revision
file.previewClientVersionStringVersion of preview client that generated preview
file.specialDirStringType of special folder, if present
file.originalFileIdOptStringExist only for version and contained file id
file.creatorIsDeletedBooleanShow that creator is deleted
file.editorIsDeletedBooleanShow that editor is deleted
file.ownerIsDeletedBooleanShow that owner is deleted
file.ownerAvatarStringOwner avatar
file.creatorAvatarStringCreator avatar
file.editorAvatarStringEditor avatar
file.oldPathStringOld file path
file.parentFolderNameStringThe name of the parent folder
file.properties[].idStringThe file’s property id
file.properties[].keyStringThe file’s property key
file.properties[].valueStringThe file’s property value
links[].relStringLink type
links[].hrefStringLink reference
  1. Example request
curl 'http://localhost:8080/api/v1/files/189327754/revisions/189328052/newFile' -i -X POST \
-H 'X-co-auth-token: e2d5dafebd68b1a0234754dbf48ef21f' \
-H 'Content-Type: application/x-www-form-urlencoded'
  1. Example response
HTTP/1.1 200 OK
X-co-request-id: 5863674a53526963584a32674d483241
Content-Type: application/json
Content-Length: 2414
{
"file": {
"id": "189328549",
"createdDate": "2022-04-06T15:55:02.000Z",
"creator": "testsrvdocs@tacos.devoffice.ru",
"creatorFsId": "5177189d266a4862ad93b1cda2f5ac2b",
"creatorFirstName": "r",
"creatorLastName": "t",
"creatorMiddleName": "d",
"fileSize": "20",
"filename": "testfile.txt",
"headRevisionId": "189328550",
"lastModifyingUserId": "testsrvdocs@tacos.devoffice.ru",
"lastModifyingUserFsId": "5177189d266a4862ad93b1cda2f5ac2b",
"lastModifyingUserFirstName": "r",
"lastModifyingUserLastName": "t",
"lastModifyingUserMiddleName": "d",
"mediaType": "text/plain",
"modifiedByMeDate": "2022-04-06T15:55:02.000Z",
"modifiedDate": "2022-04-06T15:55:02.000Z",
"ownerFsId": "5177189d266a4862ad93b1cda2f5ac2b",
"ownerId": "testsrvdocs@tacos.devoffice.ru",
"parentId": "189327645",
"properties": [
{
"id": "sharedParent",
"key": "sharedParent",
"value": "true"
}
],
"totalSize": "20",
"checksum": "e0e102b9ff40785fac8902d8bcbf2279",
"tree": "/docs-test-createNewFileFromRevisionExample()-lmEXDUEOxn/New Folder/testfile.txt",
"ownerFirstName": "r",
"ownerLastName": "t",
"ownerMiddleName": "d",
"isVersion": false,
"creatorIsDeleted": false,
"editorIsDeleted": false,
"ownerIsDeleted": false,
"ownerAvatar": "a00bbb30-993e-4632-925f-152939195049",
"creatorAvatar": "a00bbb30-993e-4632-925f-152939195049",
"editorAvatar": "a00bbb30-993e-4632-925f-152939195049"
},
"links": [
{
"rel": "self",
"href": "http://localhost:8080/api/v1/files/189328549"
},
{
"rel": "download",
"href": "http://localhost:8080/api/v1/files/189328549/content"
},
{
"rel": "import",
"href": "http://localhost:8080/api/v1/files/189328549/import"
},
{
"rel": "preview",
"href": "http://localhost:8080/api/v1/files/189328549/preview"
},
{
"rel": "link",
"href": "http://localhost:8080/link/189328549"
}
]
}