All files / platform/core/src/utils b64toBlob.js

7.14% Statements 1/14
0% Branches 0/2
0% Functions 0/1
8.33% Lines 1/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  34x                                          
/* Enabled JPEG images downloading on IE11. */
const b64toBlob = (b64Data, contentType = '', sliceSize = 512) => {
  const byteCharacters = atob(b64Data);
  const byteArrays = [];
 
  for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
    const slice = byteCharacters.slice(offset, offset + sliceSize);
 
    const byteNumbers = new Array(slice.length);
    for (let i = 0; i < slice.length; i++) {
      byteNumbers[i] = slice.charCodeAt(i);
    }
 
    const byteArray = new Uint8Array(byteNumbers);
    byteArrays.push(byteArray);
  }
 
  const blob = new Blob(byteArrays, { type: contentType });
  return blob;
};
 
export default b64toBlob;