export type UpdateApiFileStoreUuidFileArgs = {uuid: unknown, body: BodyInit}; export type UpdateApiFileStoreUuidFileOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Upload file item contents * * PUT /file_store/{uuid}/file */ export const updateApiFileStoreUuidFile = async (args: UpdateApiFileStoreUuidFileArgs, options: UpdateApiFileStoreUuidFileOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/file_store/${encodeURIComponent(String(args.uuid))}/file${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };