2018-03-03 01:54:38 +00:00
|
|
|
export function base64StringToBlob (base64, type) {
|
|
|
|
function binaryStringToArrayBuffer (binary) {
|
2019-08-03 20:49:37 +00:00
|
|
|
const length = binary.length
|
|
|
|
const buf = new ArrayBuffer(length)
|
|
|
|
const arr = new Uint8Array(buf)
|
2018-03-03 01:54:38 +00:00
|
|
|
let i = -1
|
|
|
|
while (++i < length) {
|
|
|
|
arr[i] = binary.charCodeAt(i)
|
|
|
|
}
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2019-08-03 20:49:37 +00:00
|
|
|
const parts = [binaryStringToArrayBuffer(atob(base64))]
|
2018-08-30 04:42:57 +00:00
|
|
|
return type ? new Blob(parts, { type: type }) : new Blob(parts)
|
2018-03-03 01:54:38 +00:00
|
|
|
}
|