Skip to content

Commit 12a00bc

Browse files
committed
Merge remote-tracking branch 'origin/MC-17882' into 2.2-develop-pr34
2 parents 72129a3 + e6b0582 commit 12a00bc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

lib/web/mage/msie/file-reader.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery'
7+
], function ($) {
8+
'use strict';
9+
10+
/**
11+
* Init "readAsBinaryString" function for FileReader class.
12+
* It need for IE11
13+
* @param {Blob} fileData
14+
*/
15+
var readAsBinaryStringIEFunc = function (fileData) {
16+
var binary = '',
17+
self = this,
18+
reader = new FileReader();
19+
20+
/**
21+
* Read file as binary string
22+
*/
23+
reader.onload = function () {
24+
var bytes, length, index;
25+
26+
bytes = new Uint8Array(reader.result);
27+
length = bytes.length;
28+
29+
for (index = 0; index < length; index++) {
30+
binary += String.fromCharCode(bytes[index]);
31+
}
32+
//self.result - readonly so assign binary
33+
self.content = binary;
34+
$(self).trigger('onload');
35+
};
36+
reader.readAsArrayBuffer(fileData);
37+
};
38+
39+
if (typeof FileReader.prototype.readAsBinaryString === 'undefined') {
40+
FileReader.prototype.readAsBinaryString = readAsBinaryStringIEFunc;
41+
}
42+
});

0 commit comments

Comments
 (0)