How do I replace the file representation of an asset ?
1 - First upload the new file using the temporary files resource collection : /api/dam/files
Sample request:
POST /api/dam/files
X-KPK-FileName: test.jpg
Content-Type: image/jpeg
Content-Length: 12314564
<test.jpg content>
If the upload is successful, the API returns a 201 Created
status code and a file descriptor.
Sample response:
HTTP/1.1 201 Created
Location: http://baobab.keepeek.com/api/dam/files/df1234ac
Content-Type: application/json+hal,[...]
{
"id":"df1234ac",
"expirationDate":"2019-03-29T09:21:55.523Z",
"fileName":"test.jpg",
"fileContentType":"image/jpeg",
"size":"12314564",
"_links":{
"self":"http://baobab.keepeek.com/api/dam/files/df1234ac"
}
}
2 - Then use the file descriptor link returned in the Location header or in the _links
property to create a new file version for the asset
This is done by sending a POST request on the file-versions collection of a given media.
Sample request:
POST /api/dam/medias/{mediaId}/file-versions
Content-Type: application/json
{
"_links":
{
"from":
{
"href": "http://baobab.keepeek.com/api/dam/files/df1234ac"
}
}
}
If the creation is successful, the API returns a 201 Created
status code.