How to download multiple media in a ZIP file ?
To download multiple media as a ZIP file, you will need to create a selection, then request an export of this selection.
- Search for the media Id you want to download
GET /api/dam/search/media?q=...
-
Create a selection for the current-user. (you can follow the link in
kpk:current-user
in the/api/dam
representation, then thekpk:selections
link in current-user representation) and get the id of the created selection.POST /api/dam/users/1234/selections HTTP/1.1 201 Created Location: http://baobab.keepeek.com//api/dam/users/1234/selections/ay4tvio3 Content-Type: application/json+hal,[...] { "id": "ay4tvio3", "expirationDate": "2019-03-28T18:29:31.625Z", "mediaCount": 0, "_links": { "self": { "href": "http://baobab.keepeek.com/api/dam/users/1234/selections/ay4tvio3" }, "curies": [ { "name": "kpk", "href": "http://baobab.keepeek.com/api/doc/rels/{rel}", "templated": true } ], "kpk:medias": { "href": "http://baobab.keepeek.com/api/dam/users/2/selections/ay4tvio3/medias" }, "kpk:terms-of-use": { "href": "http://baobab.keepeek.com/api/dam/users/2/selections/ay4tvio3/terms-of-use" }, "kpk:media-types": { "href": "http://baobab.keepeek.com/api/dam/users/2/selections/ay4tvio3/media-types" }, "kpk:exports": { "href": "http://baobab.keepeek.com/api/dam/users/2/selections/ay4tvio3/exports" }, "kpk:bulks": { "href": "http://baobab.keepeek.com/api/dam/users/2/selections/ay4tvio3/bulks" } } }
-
Add all your media in your selection by issuing POST request for every media in the medias representation of the selection :
POST /api/dam/users/1234/selections/ay4tvio3/medias Content-Type: application/json { "id" : 101 } HTTP/1.1 201 Created Location: http://baobab.keepeek.com//api/dam/users/1234/selections/ay4tvio3/medias/101
Or Add all your media in your selection by issuing POST request in the medias-collection representation of the selection with all your medias ids :
POST /api/dam/users/1234/selections/ay4tvio3/medias-collection Content-Type: application/json { "ids": [ 6646, 1906 ] } HTTP/1.1 201 Created
-
Look for available export formats for the selection by following the
kpk:media-types
links in the selection. Available export formats will depend on the type of media in the selection.If all media in the selection are pictures, you will retrieve the export formats with :
GET http://baobab.keepeek.com/api/dam/users/1234/selections/ay4tvio3/media-types/PICTURE/export-formats
{ "id": 1, "title": "Original files", "description": "Original media format. For high resolution print (300dpi).", "_links": { "self": { "href": "http://[...]/api/dam/users/2/selections/ay4tvio3/media-types/PICTURE/export-formats/1" }, "icon": { "href": "http://baobab.keepeek.com/images/customFormat/media/112/media-1.png" } } }, { "id": 2, "title": "For the web", "description": "To be used on your web site (200px, 72 DPI).", "_links": { "self": { "href": "http://[...]/api/dam/users/2/selections/ay4tvio3/media-types/PICTURE/export-formats/2" }, "icon": { "href": "http://baobab.keepeek.com/images/customFormat/media/112/media-1.png" } } },
- Send an export request for the selection by sending a POST request to the selection. The created export link will be returned in the
Location
header of the response. -
The
acceptTermsOfUse
property must be provided and reflect user's acceptance. Third party application must provide a convenient access for the user to the related terms of use. Theterms-of-use
relation allows to retrieve terms of use for the selection medias.If the user is not an administrator, the
usage
property is mandatory.The export format parameters must be passed through the _links property :
POST /api/dam/users/1234/selections/ay4tvio3/exports Content-Type: application/json { "acceptTermsOfUse":true, "usage":"Sample API document usage", "_links": { "kpk:picture-export-format": { "href": "http://baobab.keepeek.com/api/dam/users/1234/selections/ay4tvio3/media-types/PICTURE/export-formats/1" } } }
HTTP/1.1 201 Created Location http://baobab.keepeek.com/api/dam/users/1234/exports/orab9emb
- The zip file will take some time to be generated. You have to poll the export request (every 5 seconds is fine) until the status is
FINISHED
. -
Response when export is still being created :
GET http://baobab.keepeek.com/api/dam/users/1234/exports/orab9emb { "id": "orab9emb", "status": "RUNNING", "creationDate": "2019-03-28T17:05:39.953Z", ...
Response when export is ready :
{ "id": "orab9emb", "status": "FINISHED", "creationDate": "2019-03-28T17:05:39.953Z", "updateDate": "2019-03-28T17:13:26.536Z", "_links": { "self": { "href": "http://baobab.keepeek.com/api/dam/users/1234/exports/orab9emb" }, "curies": [ { "name": "kpk", "href": "http://baobab.keepeek.com/api/doc/rels/{rel}", "templated": true } ], "kpk:terms-of-use": { "href": "http://baobab.keepeek.com/api/dam/users/1234/exports/orab9emb/terms-of-use" }, "kpk:from": { "href": "http://baobab.keepeek.com/api/dam/users/1234/selections/ay4tvio3" }, "kpk:target": { "href": "http://baobab.keepeek.com/cache/domain2/2/Keepeek-Export-smiopi7p-28-03-2019-18-13-09.zip" } } }
- Download the zip file referenced by the
kpk:target
link in response -
Delete the selection using a DELETE request on the selection :
DELETE /api/dam/users/1234/selections/ay4tvio3
For more details please refer to the exports relation