fix
This commit is contained in:
@@ -60,3 +60,21 @@ export const downImgListToZip = async (imagesParams,callback) => {
|
||||
})
|
||||
.catch((error) => console.error('下载失败:', error))
|
||||
}
|
||||
|
||||
/** base64转二进制 */
|
||||
export const base64Tofile = (base64: string,name: string) => {
|
||||
const arr = base64.split(',')
|
||||
const mime = arr[0].match(/:(.*?);/)[1]
|
||||
const bstr = atob(arr[1])
|
||||
// 2. 转换为 Uint8Array
|
||||
let n = bstr.length
|
||||
const u8arr = new Uint8Array(n)
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n)
|
||||
}
|
||||
// 3. 创建 Blob
|
||||
const blob = new Blob([u8arr], { type: mime })
|
||||
// 4. 创建 File 对象(可选)
|
||||
const file = new File([blob], name, { type: mime })
|
||||
return file
|
||||
}
|
||||
Reference in New Issue
Block a user