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
+27 -1
View File
@@ -642,10 +642,36 @@ class GeoApiClient {
return this.request("/v1/assets", { method: "POST", body: input });
}
async getAssetSignedUploadUrl(assetId, contentType) {
return this.request(`/v1/assets/${assetId}/signed-upload`, {
const response = await this.request(`/v1/assets/${assetId}/signed-upload`, {
method: "POST",
body: { contentType: contentType ?? "application/octet-stream" }
});
if (response.url.startsWith("/")) {
response.url = this.resolveRelativeLink(response.url);
}
return response;
}
async uploadAssetBinary(assetId, payload, contentType = "application/octet-stream") {
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(() => ({}));
let msg = maybeJson.error ?? `Upload failed (${res.status})`;
if (maybeJson.hint)
msg += `. ${maybeJson.hint}`;
throw new Error(msg);
}
}
async setAssetVisibility(assetId, isPublic) {
return this.request(`/v1/assets/${assetId}`, {