From f333a9af74df1ea9be058860bfd7796b1e0a6ff6 Mon Sep 17 00:00:00 2001 From: Ilker Kulgu Date: Wed, 23 Aug 2017 09:30:36 +0200 Subject: [PATCH] IE & Edge fix for downloading blob files, gives option to save or open the file when the link is opened. --- themes/default/public/js/lufi-down.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/themes/default/public/js/lufi-down.js b/themes/default/public/js/lufi-down.js index 3285fdf..671c302 100644 --- a/themes/default/public/js/lufi-down.js +++ b/themes/default/public/js/lufi-down.js @@ -97,7 +97,13 @@ function spawnWebsocket(pa) { var pbd = $('#pbd'); pbd.attr('class', 'center-align'); - var blobURL = URL.createObjectURL(blob); + // IE & Edge fix for downloading blob files, gives option to save or open the file when the link is opened. + if (window.navigator && window.navigator.msSaveOrOpenBlob) { + var fileName = escapeHtml(data.name); + window.navigator.msSaveOrOpenBlob(blob, fileName); + } else { + var blobURL = URL.createObjectURL(blob); + } var innerHTML = ['

', i18n.download, '

']; if (data.type.match(/^image\//) !== null) {