Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1x | export const dataURLtoFile = (dataUrl: string, filename: string) => { const arr = dataUrl.split(','); const mimeType = arr[0].match(/:(.*?);/)?.[1]; const decodedData = atob(arr[1]); let lengthOfDecodedData = decodedData.length; const u8array = new Uint8Array(lengthOfDecodedData); while (lengthOfDecodedData > -1) { u8array[lengthOfDecodedData] = decodedData.charCodeAt(lengthOfDecodedData); lengthOfDecodedData -= 1; } return new File([u8array], filename, { type: mimeType }); }; |