1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-25 07:37:46 +02:00
keeweb/app/scripts/util/ui/file-saver.js

23 lines
499 B
JavaScript
Raw Normal View History

2019-09-15 14:16:32 +02:00
import { Timeouts } from 'const/timeouts';
2019-01-06 15:38:03 +01:00
const FileSaver = {
saveAs(blob, name) {
const link = document.createElement('a');
link.download = name;
link.rel = 'noopener';
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => {
URL.revokeObjectURL(link.href);
2019-09-15 14:16:32 +02:00
}, Timeouts.LinkDownloadRevoke);
2019-01-06 15:38:03 +01:00
}
};
2019-09-15 14:16:32 +02:00
export { FileSaver };