export type GetApiSystemFileExplorerDownloadArgs = {id: string, hash?: string | undefined, auth?: string | undefined}; export type GetApiSystemFileExplorerDownloadOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a file * * GET /system/file-explorer/download */ export const getApiSystemFileExplorerDownload = async (args: GetApiSystemFileExplorerDownloadArgs, options: GetApiSystemFileExplorerDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.id != null) query.append("id", String(args.id)) if (args.hash != null) query.append("hash", String(args.hash)) if (args.auth != null) query.append("auth", String(args.auth)) if (BearerAuth !== undefined) headers.set("Authorization", BearerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/system/file-explorer/download${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };