u
This commit is contained in:
21
README.md
21
README.md
@@ -156,7 +156,7 @@ Backend mapping:
|
||||
sort,
|
||||
full: { w, h, size }, // AVIF, max 1000×1000 (stored as-is when already AVIF and within bounds)
|
||||
thumb: { w, h }, // scaled AVIF, max 200×200 (fit inside)
|
||||
hash, // SHA-256 hex of full image bytes
|
||||
fullHash, // SHA-256 hex — use for GET /api/image/:fullHash and GET /api/thumb/:fullHash
|
||||
thumbHash, // base64 thumbhash of thumb preview
|
||||
}
|
||||
```
|
||||
@@ -190,20 +190,25 @@ Auth via the article's `categoryarticle` category + `resolveCategoryAccess`. Err
|
||||
|
||||
## `pic`
|
||||
|
||||
Lookup by `pic.hash` (SHA-256 hex from `addImage`), not `thumbhash`.
|
||||
Lookup by `pic.hash` (`fullHash` — SHA-256 hex from `addImage.fullHash`), not `thumbhash`.
|
||||
|
||||
| Method | Signature | Returns |
|
||||
| --- | --- | --- |
|
||||
| `getImageByHash` | `(googleAuthId, hash)` | `{ buffer, w, h, size, contentType }` |
|
||||
| `getThumbByHash` | `(googleAuthId, hash)` | `{ buffer, w, h, contentType }` |
|
||||
| `getImageByHash` | `(googleAuthId, fullHash)` | `{ buffer, w, h, size, contentType }` |
|
||||
| `getThumbByHash` | `(googleAuthId, fullHash)` | `{ buffer, w, h, contentType }` |
|
||||
|
||||
Auth via `articlepic` → `categoryarticle` → `resolveCategoryAccess`. Errors: `Image not found`, `Not authorized`.
|
||||
|
||||
`contentType` is always `image/avif`. In dashback:
|
||||
`contentType` is always `image/avif`.
|
||||
|
||||
```js
|
||||
const { buffer, contentType } = await store.pic.getImageByHash(req.user.id, hash);
|
||||
// GET /api/image/:fullHash
|
||||
const { buffer, contentType } = await store.pic.getImageByHash(req.user.id, fullHash);
|
||||
res.set('Content-Type', contentType).send(buffer);
|
||||
|
||||
// GET /api/thumb/:fullHash
|
||||
const thumb = await store.pic.getThumbByHash(req.user.id, fullHash);
|
||||
res.set('Content-Type', thumb.contentType).send(thumb.buffer);
|
||||
```
|
||||
|
||||
---
|
||||
@@ -224,8 +229,8 @@ res.set('Content-Type', contentType).send(buffer);
|
||||
| `GET /api/article/:sku` | `article.getBySku(googleAuthId, sku)` |
|
||||
| `PATCH /api/article/:sku` | `article.updateBySku(googleAuthId, sku, { name })` |
|
||||
| `POST /api/article/:sku/image` | `article.addImage(googleAuthId, sku, imageBuffer)` |
|
||||
| `GET /api/image/:hash` | `pic.getImageByHash(googleAuthId, hash)` |
|
||||
| `GET /api/image/:hash/thumb` | `pic.getThumbByHash(googleAuthId, hash)` |
|
||||
| `GET /api/image/:fullHash` | `pic.getImageByHash(googleAuthId, fullHash)` |
|
||||
| `GET /api/thumb/:fullHash` | `pic.getThumbByHash(googleAuthId, fullHash)` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user