export type PatchApiUploadFileIdArgs = {'Upload-Offset': number, 'Content-Type': string, 'Tus-Resumable': string, body: BodyInit}; export type PatchApiUploadFileIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload file chunk * * PATCH /upload/{FileId} */ export const patchApiUploadFileId = async (args: PatchApiUploadFileIdArgs, options?: PatchApiUploadFileIdOptions) => { const {baseUrl = "https://docs.bimtrackapp.co", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/offset+octet-stream") if (args['Upload-Offset'] != null) headers.set("Upload-Offset", String(args['Upload-Offset'])) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args['Tus-Resumable'] != null) headers.set("Tus-Resumable", String(args['Tus-Resumable'])) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/upload/${encodeURIComponent(String(args.FileId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };