Refresh docs and client for backend-routed asset uploads.
CI / test (push) Successful in 5s

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:
2026-03-02 21:51:47 +00:00
parent e981a334ea
commit a666f1233d
9 changed files with 92 additions and 84 deletions
+34 -1
View File
@@ -260,7 +260,10 @@ export class GeoApiClient {
return this.request("/v1/assets", { method: "POST", body: input });
}
/** Request a signed upload URL for an existing asset. */
/**
* Request a backend upload URL for an existing asset.
* Backend returns a service URL (for example /v1/assets/{id}/upload), not a direct storage endpoint.
*/
async getAssetSignedUploadUrl(
assetId: string,
contentType?: string
@@ -275,6 +278,36 @@ export class GeoApiClient {
return response;
}
/**
* Upload file/binary for an existing asset through backend upload endpoint.
* Uses getAssetSignedUploadUrl internally and executes the upload request.
*/
async uploadAssetBinary(
assetId: string,
payload: BodyInit,
contentType = "application/octet-stream"
): Promise<void> {
const upload = await this.getAssetSignedUploadUrl(assetId, contentType);
const headers = new Headers();
if (contentType) {
headers.set("Content-Type", contentType);
}
if (this.accessToken) {
headers.set("Authorization", `Bearer ${this.accessToken}`);
}
const res = await fetch(upload.url, {
method: upload.method || "PUT",
headers,
body: payload,
});
if (!res.ok) {
const maybeJson = (await res.json().catch(() => ({}))) as { error?: string; hint?: string };
let msg = maybeJson.error ?? `Upload failed (${res.status})`;
if (maybeJson.hint) msg += `. ${maybeJson.hint}`;
throw new Error(msg);
}
}
/** Update asset visibility (owner only). */
async setAssetVisibility(assetId: string, isPublic: boolean): Promise<{ asset: AssetRecord; link: string }> {
return this.request(`/v1/assets/${assetId}`, {