Media
Upload files, then reference them by their integer id.
| Endpoint | What it does |
|---|---|
| GET /api/v1/site/{site}/media/ | List media, paginated |
| POST /api/v1/site/{site}/media/ | Upload one or more files |
| GET /api/v1/site/{site}/media/{slug}/ | Read one media row |
| POST /api/v1/site/{site}/media/{slug}/ | Rename it |
| DELETE /api/v1/site/{site}/media/{slug}/ | Delete it |
Uploading is multipart/form-data on the field file, up to 10 MB per file. You can send several in one call.
Request
curl -X POST \
-H "Authorization: Token $ENINE_TOKEN" \
-F "file=@hero.png" \
https://e9sites.com/api/v1/site/mysite.e9sites.com/media/
import os
import requests
with open("hero.png", "rb") as handle:
response = requests.post(
"https://e9sites.com/api/v1/site/mysite.e9sites.com/media/",
files={"file": handle},
headers={"Authorization": f"Token {os.environ['ENINE_TOKEN']}"},
)
print(response.json())
Response
{
"id": 42,
"slug": "hero-png-a1b2c3",
"filename": "hero.png",
"file_type": "png",
"is_image": true,
"url": "https://.../hero.png",
"filehash": "..."
}
Keep the id. Everywhere a file is referenced in a write, it is the integer id:
Request
curl -X POST -H "Authorization: Token $ENINE_TOKEN" -H "Content-Type: application/json" \
-d '{"media": 42}' \
https://e9sites.com/api/v1/site/mysite.e9sites.com/artifacts/web-design/
The same is true of logo, favicon, and hero_image inside a configure call. The slug is only for addressing the media row itself.