// blob = 文件流
const blobToDataURL = (blob) => {
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.addEventListener('load', () => {
resolve(reader.result); // reader.result即为包含文件内容的字符串
});
reader.readAsDataURL(blob);
});
};
返回base64编码
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCBOyBDgDASIAAhEBAxEB/8QAHwAAAQQDAQEBAQAAAAAAAAAAAAUGBwgDBAkCAQoL/8QAhBAAAQMCBAMFBQUGAwUBAAFFAQIDEQQhAAUSMQZBUQcTImFxFDKBkaEII7HB8AkVQtHh8RYzUgoXGCRictMlQ1aCphkaJig0NjhFU4WS1zVGVViiqLLExSc3REhjZGhzhJSVl7PC0kd1eIaIk9QpV....
网友评论