llm-router / apps /api /src /services /expense /shared /object-store.ts
ClaraSu's picture
Upload folder using huggingface_hub
6822ee4 verified
Raw History Blame Contribute Delete
937 Bytes
export interface IObjectStore {
upload(base64: string, key: string): Promise<void>
delete(key: string): Promise<void>
download(key: string): Promise<string>
getPublicUrl(key: string): string
}
// In-memory test double — every test in this codebase that needs object
// storage uses this instead of talking to real R2. See r2-object-store.ts
// for the live adapter.
export class FakeObjectStore implements IObjectStore {
private store = new Map<string, string>()
async upload(base64: string, key: string): Promise<void> {
this.store.set(key, base64)
}
async delete(key: string): Promise<void> {
this.store.delete(key)
}
async download(key: string): Promise<string> {
const value = this.store.get(key)
if (value === undefined) throw new Error(`FakeObjectStore: no object for key "${key}"`)
return value
}
getPublicUrl(key: string): string {
return `https://fake.r2.dev/${key}`
}
}