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