base64轉blob

export function convertBase64ToBlob (imgData,imgType) {
    let bytes=window.atob(imgData);        //去掉url的頭,並轉換爲byte  
    let imgBuffer = new ArrayBuffer(bytes.length);   //處理異常,將ascii碼小於0的轉換爲大於0  
    let imgUnit = new Uint8Array(imgBuffer);
    for (var i = 0; i < bytes.length; i++) {  
        imgUnit[i] = bytes.charCodeAt(i);  
    }  
    return new Blob( [imgBuffer] , {type: imgType});    // 'image/png'
}
相關文章
相關標籤/搜索