From abd71413c3cc3001070694d2e0066809129a33c4 Mon Sep 17 00:00:00 2001 From: R4SAS Date: Wed, 12 Jun 2019 06:29:36 +0300 Subject: [PATCH] Store Blob URL in variable --- js/privatebin.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 961fd9f1..c0bfb32e 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2533,6 +2533,9 @@ jQuery.PrivateBin = (function($, RawDeflate) { } const blob = new window.Blob([ buf ], { type: mediaType }); + // Get Blob URL + const blobUrl = window.URL.createObjectURL(blob); + // IE does not support setting a data URI on an a element // Using msSaveBlob to download if (window.Blob && navigator.msSaveBlob) { @@ -2540,14 +2543,13 @@ jQuery.PrivateBin = (function($, RawDeflate) { navigator.msSaveBlob(blob, fileName); }); } else { - $attachmentLink.attr('href', window.URL.createObjectURL(blob)); + $attachmentLink.attr('href', blobUrl); } if (typeof fileName !== 'undefined') { $attachmentLink.attr('download', fileName); } - //me.handleAttachmentPreview($attachmentPreview, attachmentData); me.handleBlobAttachmentPreview($attachmentPreview, blobUrl, mediaType); }; @@ -2800,7 +2802,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { // Firefox crashes with files that are about 1.5MB // The performance with 1MB files is bearable if (data.length > 1398488) { - Alert.showError('File too large, to display a preview. Please download the attachment.'); //TODO: is this error really neccessary? + Alert.showError('File too large, to display a preview. Please download the attachment.'); //TODO: is this error really necessary? return; } @@ -2867,7 +2869,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { // Firefox crashes with files that are about 1.5MB // The performance with 1MB files is bearable /*if (data.length > 1398488) { - Alert.showError('File too large, to display a preview. Please download the attachment.'); //TODO: is this error really neccessary? + Alert.showError('File too large, to display a preview. Please download the attachment.'); //TODO: is this error really necessary? return; }*/