const b64ToBlob = async(base64, type = 'application/octet-stream') =>{ return await (await fetch(`data:${type};base64,${base64}`)).blob() }
const blobToB64 = (blob) => new Promise((resolve, reject) => { const reader = new FileReader(); reader.onerror = reject(); reader.onload = () => { resolve(reader.result); }; reader.readAsDataURL(blob); });
const fileToBlob = async(file) => { return await (await fetch(URL.createObjectURL(file))).blob(); }
const fileToBlob = async(file) =>{ const reader = new FileReader(); const result = await new Promise((resolve, reject) => { reader.onload = () => { resolve(reader.result); }; reader.onerror = () => { reject(reader.error); }; reader.readAsArrayBuffer(file); }); return new Blob([result], { type: file.type }); }
function blobToFile(blob, fileName) { const file = new File([blob], fileName, { type: blob.type }); return file; }
function download(blob, fileName) { const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = fileName; a.click(); document.removeChild(a); URL.revokeObjectURL(url); }
const files = require.context("@/assets/avatar", true, /\.webp$/).keys(); files.forEach((item, index) => { this.avatarList.push({ code: `${index}`, url: require("../../../assets/avatar" + item.slice(1)) }) });
|