Files
dashback/docs/api/routes/article/add-image.md
2026-09-29 13:44:14 +02:00

66 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# `POST /article/{sku}/image`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Add article image
Accepts a full-size AVIF body (`Content-Type: image/avif`) or WebP body (`Content-Type: image/webp`).
WebP images are automatically converted to AVIF on the server.
Full: stored as-is when already AVIF and ≤1000×1000; otherwise scaled to max 1000×1000.
Thumb always scaled to max 200×200. Stores hash/thumbhash, links `articlepic`.
Auth like GET by SKU.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `sku` | yes | string | Article SKU |
## Body
Raw binary (`image/avif`).
Raw binary (`image/webp`).
## Signals
On success, emits SSE signal: `article-<sku>` (see [`GET /events`](../events.md)).
## Response `201`
Image stored and linked
```json
{
"image": {
"picId": 1,
"sort": 1,
"full": {
"w": 1,
"h": 1,
"size": 1
},
"thumb": {
"w": 1,
"h": 1
},
"hash": "…",
"thumbHash": "…"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Missing body or invalid image — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Article not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._