11-wms/src/utils/blobToBase64.js
2022-10-19 17:01:55 +08:00

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'))
}
})
}