From 9679dea6460a85f815a966cfd6611f4c89dcc711 Mon Sep 17 00:00:00 2001 From: Alex Kern Date: Tue, 28 Apr 2015 01:04:40 -0700 Subject: [PATCH] Make downloads work in FF. --- lib/DownloadFile.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/DownloadFile.js b/lib/DownloadFile.js index 81422cf..38492c3 100644 --- a/lib/DownloadFile.js +++ b/lib/DownloadFile.js @@ -26,13 +26,21 @@ export default class DownloadFile { } download() { + let blob = this.chunks.toBlob() let url = URL.createObjectURL(blob) + let a = document.createElement('a') + document.body.appendChild(a) a.download = this.name a.href = url a.click() - URL.revokeObjectURL(url) + + setTimeout(() => { + URL.revokeObjectURL(url) + document.body.removeChild(a) + }, 0) + } toJSON() {