How di I upload a new media in a folder?
-
First create a new media by sending a POST (create) request on the file upload 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" } }
-
Then use the file descriptor link obtained to create a media in the target directory from uploaded file using user's default form for file type. This is done by sending a POST request on the collection of media
POST /api/dam/folders/{folderId}/medias Content-Type: application/json { "_links": { "from": { "href": "http://baobab.keepeek.com/api/dam/files/df1234ac" } } }
For more details about file upload, please refer to upload relations