export function base64src(base64data, cb) {
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || [];
if (!format) {
return (new Error('ERROR_BASE64SRC_PARSE'));
}
const filePath = `${wx.env.USER_DATA_PATH}/${FILE_BASE_NAME}.${format}`;
const buffer = uni.base64ToArrayBuffer(bodyData);
console.log("buffer.byteLength===")
console.log(buffer.byteLength)
fsm.writeFile({
filePath,
data: buffer,
encoding: 'binary',
success() {
console.log("单页模式保存成功==")
console.log(filePath)
cb(filePath);
},
fail(error) {
console.log("单页模式保存报错==")
console.log(error)
return (new Error('ERROR_BASE64SRC_WRITE'));
},
});
};
知道的,帮忙看下吧
const buffer = wx.base64ToArrayBuffer(bodyData); // buffer 是undefined
const removeInvalidCharacter = (str) => {
return str.replace(/[^A-Za-z0-9+/]/g, '');
}
wx.base64ToArrayBuffer(removeInvalidCharacter('-dasds_fjkhfkj'))