export type UpdateApiUploadsIdChunkNumArgs = {id: string, chunkNum: string, body: BodyInit}; export type UpdateApiUploadsIdChunkNumOptions = {baseUrl: string, CurioAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a file chunk * * PUT /uploads/{id}/{chunkNum} */ export const updateApiUploadsIdChunkNum = async (args: UpdateApiUploadsIdChunkNumArgs, options: UpdateApiUploadsIdChunkNumOptions) => { const {baseUrl, fetch: fetchFn = fetch, CurioAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") headers.set('accept', "*/*") if (CurioAuth !== undefined) headers.set("Authorization", CurioAuth) const url = `${baseUrl.replace(/\/+$/, '')}/uploads/${encodeURIComponent(String(args.id))}/${encodeURIComponent(String(args.chunkNum))}${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 res.blob() };