export type GetApiUtilitiesDownloadsUuidFilenameArgs = {uuid: string, expires: number, sig: string, id: number, node: string}; export type GetApiUtilitiesDownloadsUuidFilenameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Download File * * GET /utilities/downloads/{uuid}/{filename} */ export const getApiUtilitiesDownloadsUuidFilename = async (args: GetApiUtilitiesDownloadsUuidFilenameArgs, options: GetApiUtilitiesDownloadsUuidFilenameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.expires != null) query.append("expires", String(args.expires)) if (args.sig != null) query.append("sig", String(args.sig)) if (args.id != null) query.append("id", String(args.id)) if (args.node != null) query.append("node", String(args.node)) const url = `${baseUrl.replace(/\/+$/, '')}/utilities/downloads/${encodeURIComponent(String(args.uuid))}/${encodeURIComponent(String(args.filename))}${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() };