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:
Vendored
+27
-1
@@ -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}`, {
|
||||
|
||||
Reference in New Issue
Block a user