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