export type CreateApiBlobsUploadsIdAppendArgs = {id: string, 'PortSIP-Upload-Token': string, body: BodyInit}; export type CreateApiBlobsUploadsIdAppendOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a chunk of data for the specified upload. * * POST /blobs/uploads/{id}/append */ export const createApiBlobsUploadsIdAppend = async (args: CreateApiBlobsUploadsIdAppendArgs, options?: CreateApiBlobsUploadsIdAppendOptions) => { const {baseUrl = "https://HOSTNAME:8887/api", fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (args['PortSIP-Upload-Token'] != null) headers.set("PortSIP-Upload-Token", String(args['PortSIP-Upload-Token'])) if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/blobs/uploads/${encodeURIComponent(String(args.id))}/append${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };