Menü REST API
Uploading a file
In this How-To we will upload a file into a folder named “Test Upload” which we will create in our “root” Folder.
We also want to version the uploaded file if it already exists.
For the initial request to create a folder we will use the id of the root folder from the previous How-To.
Step 1
Request:
Create a folder.
POST /rest/folders/225819/folders
{ "name": "Test Upload", "description": "" }
Response:
In the response we will have the id of the created Folder, which we will need for the upload.
{ "id": 225849, "name": "Test Upload", "description": "", "createdDate": "1456135638236", "modifiedDate": "1456135638258", "createdUser": { "id": 225822, "username": "REST.DEMO", "firstname": "Demo", "lastname": "Demonicum", "type": "user" }, "modifiedUser": { "id": 225822, "username": "REST.DEMO", "firstname": "Demo", "lastname": "Demonicum", "type": "user" }, "parent": { "id": 225819, "name": "Root", "type": "folder" }, "status": { "published": false, "locked": false, "type": "status" }, "sharedLink": { "url": null, "passwordEnabled": false, "password": null, "expirationDate": null, "canEdit": false, "type": "link" }, "type": "folder" }
Step 2
Request:
Upload a file “screen.png”
POST /rest/folders/225849/folders
Content-Type: “application/form-data”
Form Parameter "file" - the file "screen.png" Form Parameter "versioned" - "true"
Response:
The response will contain the id of the new file for further requests.
{ "id": 225851, "name": "screen.png", "description": "", "size": 31272, "mimeType": "image/png", "createdDate": "1456136017303", "modifiedDate": "1456136017349", "createdUser": { "id": 225822, "username": "REST.DEMO", "firstname": "Demo", "lastname": "Demonicum", "type": "user" }, "modifiedUser": { "id": 225822, "username": "REST.DEMO", "firstname": "Demo", "lastname": "Demonicum", "type": "user" }, "sharedLink": { "url": null, "passwordEnabled": false, "password": null, "expirationDate": null, "canEdit": true, "type": "link" }, "parent": { "id": 225849, "name": "Test Upload", "type": "folder" }, "status": { "published": false, "locked": false, "type": "status" }, "type": "file" }