21 lines
461 B
JavaScript
21 lines
461 B
JavaScript
/*
|
|
* @Author: gtz
|
|
* @Date: 2021-03-01 16:54:38
|
|
* @LastEditors: gtz
|
|
* @LastEditTime: 2021-03-01 16:57:00
|
|
* @Description: file content
|
|
*/
|
|
|
|
export function blobToBase64(blob) {
|
|
return new Promise((resolve, reject) => {
|
|
const fileReader = new FileReader()
|
|
fileReader.onload = (e) => {
|
|
resolve(e.target.result)
|
|
}
|
|
fileReader.readAsDataURL(blob)
|
|
fileReader.onerror = () => {
|
|
reject(new Error('blobToBase64 error'))
|
|
}
|
|
})
|
|
}
|