export type GetApiSeriesIdAttachmentsNameDataArgs = {filename?: string | undefined, 'If-None-Match'?: string | undefined, Range?: string | undefined, id: string, name: string}; export type GetApiSeriesIdAttachmentsNameDataOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get attachment * * GET /series/{id}/attachments/{name}/data */ export const getApiSeriesIdAttachmentsNameData = async (args: GetApiSeriesIdAttachmentsNameDataArgs, options?: GetApiSeriesIdAttachmentsNameDataOptions) => { const {baseUrl = "https://orthanc.uclouvain.be/demo", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.filename != null) query.append("filename", String(args.filename)) if (args['If-None-Match'] != null) headers.set("If-None-Match", String(args['If-None-Match'])) if (args.Range != null) headers.set("Range", String(args.Range)) const url = `${baseUrl.replace(/\/+$/, '')}/series/${encodeURIComponent(String(args.id))}/attachments/${encodeURIComponent(String(args.name))}/data${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() };