Download src/remoteimage.ts from engineofperplexity/gemini-openai-proxy: direct link, hf CLI and curl.
- Browser
- Download file 413 Bytes
-
https://huggingface.co/engineofperplexity/gemini-openai-proxy/resolve/main/src/remoteimage.ts
- Command line
-
hf download hf://engineofperplexity/gemini-openai-proxy/src/remoteimage.ts
-
curl -L -o remoteimage.ts https://huggingface.co/engineofperplexity/gemini-openai-proxy/resolve/main/src/remoteimage.ts
413 Bytes
| import { fetch } from 'undici'; // Node ≥18 has global fetch; otherwise add undici | |
| export async function fetchAndEncode(url: string) { | |
| const res = await fetch(url); | |
| if (!res.ok) throw new Error(`Failed to fetch image: ${url}`); | |
| const buf = Buffer.from(await res.arrayBuffer()); | |
| const mimeType = res.headers.get('content-type') || 'image/png'; | |
| return { mimeType, data: buf.toString('base64') }; | |
| } | |