Upload a file to a page
Contents
Upload a file to a specific page's uploads directory. The filename is sanitised (special characters and spaces replaced with -); only extensions in Bludit's ALLOWED_FILE_EXTENSIONS list are accepted.
Requires the API Token and an Authentication Token. See Authentication.
HTTP Request
POST /api/files/{key}
The body must be multipart/form-data with a file field named file.
Parameters
| Key | Type | Description |
|---|---|---|
token (required) |
string (form field) | API Token. |
authentication (required) |
string (form field) | User Authentication Token. |
file (required) |
file | The file to upload. |
Response
HTTP Code: 200
Content-Type: application/json
Body:
{
"status": "0",
"message": "File uploaded.",
"filename": "report.pdf",
"absolutePath": "/var/www/.../bl-content/uploads/pages/my-dog/report.pdf",
"absoluteURL": "https://www.example.com/bl-content/uploads/pages/my-dog/report.pdf"
}
Errors
| Code | Reason |
|---|---|
400 |
No file sent, upload error, dotfile filename, or unsupported extension. |
400 |
Page key contains path-traversal characters (.. or null byte). |
401 |
Missing or invalid authentication token. |
500 |
The file failed to move from the temporary directory to the page's uploads directory. |
CURL command example
$ curl -X POST \
-F "token=<api-token>" \
-F "authentication=<auth-token>" \
-F "[email protected]" \
"https://www.example.com/api/files/my-dog"