diff --git a/app/src/media/api/MediaApi.ts b/app/src/media/api/MediaApi.ts index d925d4d..591d0eb 100644 --- a/app/src/media/api/MediaApi.ts +++ b/app/src/media/api/MediaApi.ts @@ -76,6 +76,7 @@ export class MediaApi extends ModuleApi { filename?: string; path?: TInput; _init?: Omit; + query?: Record; }, ): FetchPromise> { const headers = { @@ -102,14 +103,22 @@ export class MediaApi extends ModuleApi { headers, }; if (opts?.path) { - return this.post(opts.path, body, init); + return this.request(opts.path, opts?.query, { + ...init, + body, + method: "POST", + }); } if (!name || name.length === 0) { throw new Error("Invalid filename"); } - return this.post(opts?.path ?? ["upload", name], body, init); + return this.request(opts?.path ?? ["upload", name], opts?.query, { + ...init, + body, + method: "POST", + }); } async upload( @@ -119,6 +128,7 @@ export class MediaApi extends ModuleApi { _init?: Omit; path?: TInput; fetcher?: ApiFetcher; + query?: Record; } = {}, ) { if (item instanceof Request || typeof item === "string") { @@ -155,11 +165,14 @@ export class MediaApi extends ModuleApi { opts?: { _init?: Omit; fetcher?: typeof fetch; + overwrite?: boolean; }, ): Promise> { + const query = opts?.overwrite !== undefined ? { overwrite: opts.overwrite } : undefined; return this.upload(item, { ...opts, path: ["entity", entity, id, field], + query, }); }