Added support to download QR codes to the QR code modal

This commit is contained in:
Alejandro Celaya
2021-08-16 13:12:07 +02:00
parent 2b5420a429
commit eb90aa2274
8 changed files with 64 additions and 14 deletions

View File

@@ -0,0 +1,13 @@
import { AxiosInstance } from 'axios';
import { saveUrl } from '../../utils/helpers/files';
export class ImageDownloader {
public constructor(private readonly axios: AxiosInstance, private readonly window: Window) {}
public async saveImage(imgUrl: string, filename: string): Promise<void> {
const { data } = await this.axios.get(imgUrl, { responseType: 'blob' });
const url = URL.createObjectURL(data);
saveUrl(this.window, url, filename);
}
}