|
|
|
@ -1925,7 +1925,37 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|
|
|
|
{
|
|
|
|
|
var imagePrefix = 'data:image/';
|
|
|
|
|
|
|
|
|
|
$attachmentLink.attr('href', attachmentData);
|
|
|
|
|
// IE does not support setting a data URI on an a element
|
|
|
|
|
// Convert dataURI to a Blob and use msSaveBlob to download
|
|
|
|
|
if (window.Blob && navigator.msSaveBlob) {
|
|
|
|
|
$attachmentLink.off('click').on('click', function () {
|
|
|
|
|
// data URI format: data:[<mediaType>][;base64],<data>
|
|
|
|
|
|
|
|
|
|
// position in data URI string of where data begins
|
|
|
|
|
var base64Start = attachmentData.indexOf(',') + 1;
|
|
|
|
|
// position in data URI string of where mediaType ends
|
|
|
|
|
var mediaTypeEnd = attachmentData.indexOf(';');
|
|
|
|
|
|
|
|
|
|
// extract mediaType
|
|
|
|
|
var mediaType = attachmentData.substring(5, mediaTypeEnd);
|
|
|
|
|
// extract data and convert to binary
|
|
|
|
|
var decodedData = Base64.atob(attachmentData.substring(base64Start));
|
|
|
|
|
|
|
|
|
|
// Transform into a Blob
|
|
|
|
|
var decodedDataLength = decodedData.length;
|
|
|
|
|
var buf = new Uint8Array(decodedDataLength);
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < decodedDataLength; i++) {
|
|
|
|
|
buf[i] = decodedData.charCodeAt(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var blob = new window.Blob([ buf ], { type: mediaType });
|
|
|
|
|
navigator.msSaveBlob(blob, fileName);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$attachmentLink.attr('href', attachmentData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof fileName !== 'undefined') {
|
|
|
|
|
$attachmentLink.attr('download', fileName);
|
|
|
|
|
}
|
|
|
|
@ -1971,6 +2001,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|
|
|
|
me.hideAttachmentPreview();
|
|
|
|
|
$attachmentLink.prop('href', '');
|
|
|
|
|
$attachmentLink.prop('download', '');
|
|
|
|
|
$attachmentLink.off('click');
|
|
|
|
|
$attachmentPreview.html('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|