Spaces:
Paused
Paused
Download web/src/lib/storage/index.ts from Lordgrim7/cobalt-api: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/spaces/Lordgrim7/cobalt-api/resolve/main/web/src/lib/storage/index.ts
- Command line
-
hf download hf://spaces/Lordgrim7/cobalt-api/web/src/lib/storage/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/Lordgrim7/cobalt-api/resolve/main/web/src/lib/storage/index.ts
552 Bytes
| import type { AbstractStorage } from "./storage"; | |
| import { MemoryStorage } from "./memory"; | |
| import { OPFSStorage } from "./opfs"; | |
| export async function init(expectedSize?: number): Promise<AbstractStorage> { | |
| if (await OPFSStorage.isAvailable()) { | |
| return OPFSStorage.init(); | |
| } | |
| if (await MemoryStorage.isAvailable()) { | |
| return MemoryStorage.init(expectedSize || 0); | |
| } | |
| throw "no storage method is available"; | |
| } | |
| export function retype(file: File, type: string) { | |
| return new File([ file ], file.name, { type }); | |
| } | |