Spaces:
Paused
Paused
Download node_modules/@huggingface/hub/src/utils/createBlob.ts from Leon4gr45/nova-header-nav: direct link, hf CLI and curl.
- Browser
- Download file 902 Bytes
-
https://huggingface.co/spaces/Leon4gr45/nova-header-nav/resolve/main/node_modules/%40huggingface/hub/src/utils/createBlob.ts
- Command line
-
hf download hf://spaces/Leon4gr45/nova-header-nav/node_modules/@huggingface/hub/src/utils/createBlob.ts
-
curl -L -o createBlob.ts https://huggingface.co/spaces/Leon4gr45/nova-header-nav/resolve/main/node_modules/%40huggingface/hub/src/utils/createBlob.ts
902 Bytes
| import { WebBlob } from "./WebBlob"; | |
| import { isFrontend } from "./isFrontend"; | |
| /** | |
| * This function allow to retrieve either a FileBlob or a WebBlob from a URL. | |
| * | |
| * From the backend: | |
| * - support local files | |
| * - support http resources with absolute URLs | |
| * | |
| * From the frontend: | |
| * - support http resources with absolute or relative URLs | |
| */ | |
| export async function createBlob(url: URL, opts?: { fetch?: typeof fetch; accessToken?: string }): Promise<Blob> { | |
| if (url.protocol === "http:" || url.protocol === "https:") { | |
| return WebBlob.create(url, { fetch: opts?.fetch, accessToken: opts?.accessToken }); | |
| } | |
| if (isFrontend) { | |
| throw new TypeError(`Unsupported URL protocol "${url.protocol}"`); | |
| } | |
| if (url.protocol === "file:") { | |
| const { FileBlob } = await import("./FileBlob"); | |
| return FileBlob.create(url); | |
| } | |
| throw new TypeError(`Unsupported URL protocol "${url.protocol}"`); | |
| } | |