Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste the uploaded image to directly call up the get method, there is no set #8684

Closed
xiaogonggong-w opened this issue Nov 6, 2024 · 0 comments

Comments

@xiaogonggong-w
Copy link

export class MockServerBlobSource implements BlobSource {
private readonly _cache = new Map<string, Blob>();

readonly = false;

constructor(readonly name: string) { }

async delete(key: string) {
console.log(delete ${key});

this._cache.delete(key);
await deleteImage(key)

}

async get(key: string) {
if (this._cache.has(key)) {
return this._cache.get(key) as Blob;
} else {
const blob = await getImage(key)
this._cache.set(key, blob);
return blob;
}
}

// eslint-disable-next-line @typescript-eslint/require-await
async list() {
return Array.from(this._cache.keys());
}

async set(key: string, value: Blob) {
this._cache.set(key, value);
const formData = new FormData();
formData.append('file_hash', key);
formData.append('file', value);
await saveImage(formData);
return key;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

1 participant