Best practices: upload large files easily to Keepeek platform
Large files: use chunk strategy
To upload large files you will need to use chunked and resumable file upload.
You have to use chunked and resumable file upload for file larger than 50MB but we recommend to use it for file larger than 20MB.
For that, you will need to first send a post requests to `/api/dam/files`.
You will need to set differents header :
- X-KPK-Upload-Content-Type: the content type
- X-KPK-Upload-Content-Length: the content length of the file via custom header
- Content-Length: You need to set the value 0
For the filename of the file you need to set:
- X-KPK-Base64FileName: Keepeek custom HTTP header to send base64 file name (strongly recommended)
OR
- X-KPK-FileName: Keepeek custom HTTP header to send the original file name (ISO-8859-1)
Here is an example of the first call:
POST http://baobab.keepeek.com/api/dam/files
X-KPK-Base64FileName: dGVzdC5tcDQ=
X-KPK-Upload-Content-Type: video/mp4
X-KPK-Upload-Content-Length: 535010012
Content-Length: 0
You will receive this response :
HTTP/1.1 201 Created
Location: http://baobab.keepeek.com/api/dam/files/5fa23b4ac
Content-Type: application/json
{
"id":"5fa23b4ac",
"expirationDate":"2015-01-29T09:21:55.523Z",
"fileName":"test.mp4",
"fileContentType":"video/mp4",
"size":"535010012",
"nextExpectedRanges": ["0-"],
"_links":{
"self":"http://baobab.keepeek.com/api/dam/files/5fa23b4ac"
}
}
The response is composed of:
- id: the ressource if of the file
- expirationDate: the expiration date of the file ressource
- fileContentType: content type of the file
- size: size of the file
- nextExpectedRanges: the range expected for the next call (more on that later)
- _links.self: url to call for the upload itself
Now that the ressource is created, you need to send the file by chunks.
Call the _links.self url with the HTTP PUT method.
You will need to set different headers:
- Content-Length: size of your chunk
- Content-Range: the content range of your chunk (value received in response of the ressource creation)
Also you need to send a chunk of your file as a payload.
PUT http://baobab.keepeek.com/api/dam/files/5fa23b4ac
Content-Length: 20000000
Content-Range: bytes 0-19999999/535010012
<test.mp4 content (20 first Mb)>
You will receive this response
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"id":"5fa23b4ac",
"expirationDate":"2015-01-29T09:21:55.523Z",
"fileName":"test.mp4",
"fileContentType":"video/mp4",
"size":"535010012",
"nextExpectedRanges": ["20000000-"],
"_links":{
"self":"http://baobab.keepeek.com/api/dam/files/5fa23b4ac"
}
}
The response is composed of:
- id: the ressource if of the file
- expirationDate: the expiration date of the file ressource
- fileName: name of the file
- fileContentType: content type of the file
- size: size of the file
- nextExpectedRanges: the range expected for the next call (more on that later)
- _links.self: url to call for the upload itself
First response:
{
"id": "tcyvlvqk",
"expirationDate": "2024-11-06T18:44:22.289Z",
"fileName": "video-test.mp4",
"fileContentType": "video/mp4",
"size": 391309378,
"nextExpectedRanges": [
"0-"
],
"_links": {
"self": {
"href": "https://qualification.ci.keepeek-dev.com/api/dam/files/tcyvlvqk"
}
}
}
Second response:
{
"id": "tcyvlvqk",
"expirationDate": "2024-11-06T18:44:22.000Z",
"fileName": "video-test.mp4",
"fileContentType": "video/mp4",
"size": 391309378,
"nextExpectedRanges": [
"20000000-"
],
"_links": {
"self": {
"href": "https://qualification.ci.keepeek-dev.com/api/dam/files/tcyvlvqk"
}
}
}
Third response:
{
"id": "tcyvlvqk",
"expirationDate": "2024-11-06T18:48:45.000Z",
"fileName": "video-test.mp4",
"fileContentType": "video/mp4",
"size": 391309378,
"nextExpectedRanges": [
"40000000-"
],
"_links": {
"self": {
"href": "https://qualification.ci.keepeek-dev.com/api/dam/files/tcyvlvqk"
}
}
}
Try it yourself !
We are going to split a file into 20MB chunks and send it through postman !
Split the file
To split the file, we are using the command line `split`
```bash
split -b 20M video.mp4 -d -a 3 part_
```
This create small files as part_000, part_001, part_002, etc
You can now create the file on Keepeek and send the chunks by following the steps ahead !
Tips
- Use chunks upload for assets larger than 20MB
- Use the the header X-KPK-Base64FileName to not have to worry about the encoding of the title
Upload limits
- Max size of media / files : 20GB officially supported, beyond it can creates performance issues and timeout.
- Max number of simultaneous upload of media / files: 200
- Use chunks of 20MB maximum
- Simultaneous chunk upload of the same media are not supported