1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
export function dataURLtoFile(dataurl: string, filename: string) { const arr = dataurl.split(',') const bstr = window.atob(arr[1]) let n = bstr.length const u8arr = new Uint8Array(n) while (n--) { u8arr[n] = bstr.charCodeAt(n) } return new File([u8arr], filename, { type: 'image/jpeg', }) }
|