export type CreateApiApiV1TusUploadSessionUploadSessionIdUploadArgs = {upload_session_id: string, force?: boolean | undefined, 'Upload-Length': number, 'Upload-Metadata': string, 'Tus-Resumable': string, body: {[key: string]: unknown}}; export type CreateApiApiV1TusUploadSessionUploadSessionIdUploadOptions = {baseUrl: string, AuthToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an Upload * * POST /api/v1/tus/upload-session/{upload_session_id}/upload/ */ export const createApiApiV1TusUploadSessionUploadSessionIdUpload = async (args: CreateApiApiV1TusUploadSessionUploadSessionIdUploadArgs, options: CreateApiApiV1TusUploadSessionUploadSessionIdUploadOptions) => { const {baseUrl, fetch: fetchFn = fetch, AuthToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.force != null) headers.set("force", String(args.force)) if (args['Upload-Length'] != null) headers.set("Upload-Length", String(args['Upload-Length'])) if (args['Upload-Metadata'] != null) headers.set("Upload-Metadata", String(args['Upload-Metadata'])) if (args['Tus-Resumable'] != null) headers.set("Tus-Resumable", String(args['Tus-Resumable'])) if (AuthToken !== undefined) headers.set("Authorization", AuthToken) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/tus/upload-session/${encodeURIComponent(String(args.upload_session_id))}/upload/${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 undefined };