export type GetApiApiReposNamespaceRepoNameFileResourceArgs = {namespace: string, repo_name: string, resource: string, width?: number | undefined, height?: number | undefined, timestamp?: number | undefined, thumbnail?: boolean | undefined}; export type GetApiApiReposNamespaceRepoNameFileResourceOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download File * * GET /api/repos/{namespace}/{repo_name}/file/{resource} */ export const getApiApiReposNamespaceRepoNameFileResource = async (args: GetApiApiReposNamespaceRepoNameFileResourceArgs, options?: GetApiApiReposNamespaceRepoNameFileResourceOptions) => { const {baseUrl = "https://hub.oxen.ai", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.width != null) query.append("width", String(args.width)) if (args.height != null) query.append("height", String(args.height)) if (args.timestamp != null) query.append("timestamp", String(args.timestamp)) if (args.thumbnail != null) query.append("thumbnail", String(args.thumbnail)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/repos/${encodeURIComponent(String(args.namespace))}/${encodeURIComponent(String(args.repo_name))}/file/${encodeURIComponent(String(args.resource))}${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() };