IE & Edge fix for downloading blob files, gives option to save or open the file when the link is opened.

This commit is contained in:
Ilker Kulgu 2017-08-23 09:30:36 +02:00 committed by Luc Didry
parent a6a58e4a07
commit f333a9af74
1 changed files with 7 additions and 1 deletions

View File

@ -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 = ['<p><a href="', blobURL, '" class="btn btn-primary" download="', escapeHtml(data.name), '">', i18n.download, '</a></p>'];
if (data.type.match(/^image\//) !== null) {