Commit 1753b72e authored by Eric Seigne's avatar Eric Seigne
Browse files

add base64toBlob

parent 6278bb78
......@@ -300,6 +300,28 @@ function dataURItoBlob(dataURI) {
return new Blob([ab], { type: mimeString });
}
//source : https://stackoverflow.com/questions/21227078/convert-base64-to-image-in-javascript-jquery
function base64toBlob(base64Data, contentType) {
contentType = contentType || '';
var sliceSize = 1024;
var byteCharacters = atob(base64Data);
var bytesLength = byteCharacters.length;
var slicesCount = Math.ceil(bytesLength / sliceSize);
var byteArrays = new Array(slicesCount);
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
var begin = sliceIndex * sliceSize;
var end = Math.min(begin + sliceSize, bytesLength);
var bytes = new Array(end - begin);
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
bytes[i] = byteCharacters[offset].charCodeAt(0);
}
byteArrays[sliceIndex] = new Uint8Array(bytes);
}
return new Blob(byteArrays, { type: contentType });
}
function ProgressBar(ele) {
this.thisEle = $(ele);
this.fileAdded = function () {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment