This updates developer docs and web demos to use backend upload endpoints, adds a client upload helper, and aligns integration tests with the no-direct-MinIO URL flow. Made-with: Cursor
This commit is contained in:
@@ -30,7 +30,8 @@ Each `properties.assets` item includes:
|
||||
1. Create or reuse an asset record and link it to a feature:
|
||||
- `POST /v1/assets`
|
||||
2. Upload the binary to object storage:
|
||||
- `POST /v1/assets/{id}/signed-upload` (returns signed PUT URL)
|
||||
- `POST /v1/assets/{id}/signed-upload` (returns backend upload URL)
|
||||
- `PUT /v1/assets/{id}/upload` (backend streams content to object storage)
|
||||
3. Read linked assets from feature responses:
|
||||
- `GET /v1/collections/{id}/features` (`properties.assets`)
|
||||
4. Download via service-relative link:
|
||||
|
||||
@@ -40,8 +40,8 @@ docker compose up --build -d
|
||||
- `http://localhost:8774`
|
||||
3. Confirm bucket exists (`momswap-assets` by default).
|
||||
4. Use API flow:
|
||||
- create asset and get signed upload URL
|
||||
- upload file with PUT
|
||||
- create asset and request backend upload URL
|
||||
- upload file with `PUT /v1/assets/{id}/upload`
|
||||
- request `/v1/assets/{id}/download`
|
||||
|
||||
## Quick verification script
|
||||
@@ -67,6 +67,6 @@ fi
|
||||
- If bucket bootstrap fails, inspect:
|
||||
- `docker compose logs minio`
|
||||
- `docker compose logs minio-init`
|
||||
- If signed URLs are generated but upload fails, check:
|
||||
- If backend upload endpoint fails, check:
|
||||
- object key path style (`S3_USE_PATH_STYLE=true` for MinIO)
|
||||
- MinIO credentials (`S3_ACCESS_KEY`, `S3_SECRET_KEY`)
|
||||
|
||||
@@ -60,6 +60,7 @@ web/
|
||||
- Leaflet map example:
|
||||
- click map to place object coordinates
|
||||
- create feature + upload/link `gltf`/`glb`/image asset
|
||||
- upload via backend endpoint (`/v1/assets/{id}/upload`)
|
||||
- copy/open share link and toggle public/private visibility
|
||||
- MapLibre GL + Three.js example:
|
||||
- vector tile basemap via MapLibre style
|
||||
|
||||
@@ -36,7 +36,7 @@ bun run build
|
||||
Integration tests in `test/integration.test.ts` cover both:
|
||||
|
||||
- Base flow: register, login, collection and feature CRUD
|
||||
- Asset flow: create/link asset, request signed upload URL, and toggle visibility
|
||||
- Asset flow: create/link asset, request backend upload URL, upload binary, and toggle visibility
|
||||
|
||||
## Public API (current)
|
||||
|
||||
@@ -77,7 +77,8 @@ Key methods:
|
||||
|
||||
- **Assets (new)**
|
||||
- `createOrLinkAsset({...})` — create metadata or reuse existing asset by checksum/ext and link it to a feature
|
||||
- `getAssetSignedUploadUrl(assetId, contentType?)` — get signed `PUT` URL for binary upload
|
||||
- `getAssetSignedUploadUrl(assetId, contentType?)` — get backend upload endpoint (`PUT /v1/assets/{id}/upload`)
|
||||
- `uploadAssetBinary(assetId, payload, contentType?)` — upload binary through backend endpoint
|
||||
- `setAssetVisibility(assetId, isPublic)` — owner toggles public/private access
|
||||
- `resolveRelativeLink(path)` — converts backend-relative asset links to absolute URLs for browser usage
|
||||
|
||||
@@ -98,8 +99,8 @@ Key methods:
|
||||
6. For media upload:
|
||||
- compute file checksum
|
||||
- call `createOrLinkAsset`
|
||||
- call `getAssetSignedUploadUrl`
|
||||
- upload file to signed URL
|
||||
- call `uploadAssetBinary` (or call `getAssetSignedUploadUrl` + manual `fetch`)
|
||||
- upload file to backend endpoint
|
||||
7. Render and share assets from `properties.assets` links.
|
||||
8. Use `setAssetVisibility` to toggle sharing.
|
||||
9. Use `importKeys`/`exportKeys` in profile settings UX.
|
||||
@@ -169,13 +170,12 @@ const asset = await client.createOrLinkAsset({
|
||||
isPublic: true,
|
||||
});
|
||||
|
||||
// Upload binary to object storage through signed URL
|
||||
const signed = await client.getAssetSignedUploadUrl(asset.asset.id, asset.asset.mimeType);
|
||||
await fetch(signed.url, {
|
||||
method: signed.method,
|
||||
headers: asset.asset.mimeType ? { "Content-Type": asset.asset.mimeType } : undefined,
|
||||
body: file,
|
||||
});
|
||||
// Upload binary through backend upload endpoint
|
||||
await client.uploadAssetBinary(
|
||||
asset.asset.id,
|
||||
file,
|
||||
asset.asset.mimeType || "application/octet-stream"
|
||||
);
|
||||
|
||||
// Read shareable relative link from feature payload
|
||||
const features = await client.listFeatures(created.id);
|
||||
|
||||
Reference in New Issue
Block a user