export type Mk20StartUpload = {chunk_size?: number | undefined, raw_size?: number | undefined}; export type CreateApiUploadsIdArgs = {id: string, body: Mk20StartUpload}; export type CreateApiUploadsIdOptions = {baseUrl: string, CurioAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Starts the upload process * * POST /uploads/{id} */ export const createApiUploadsId = async (args: CreateApiUploadsIdArgs, options: CreateApiUploadsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, CurioAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (CurioAuth !== undefined) headers.set("Authorization", CurioAuth) const url = `${baseUrl.replace(/\/+$/, '')}/uploads/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(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() };