mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 06:11:48 +00:00
14 lines
455 B
TypeScript
14 lines
455 B
TypeScript
import { Fetch } from '../../utils/types';
|
|
import { saveUrl } from '../../utils/helpers/files';
|
|
|
|
export class ImageDownloader {
|
|
public constructor(private readonly fetch: Fetch, private readonly window: Window) {}
|
|
|
|
public async saveImage(imgUrl: string, filename: string): Promise<void> {
|
|
const data = await this.fetch(imgUrl).then((resp) => resp.blob());
|
|
const url = URL.createObjectURL(data);
|
|
|
|
saveUrl(this.window, url, filename);
|
|
}
|
|
}
|