| 29 | }; |
| 30 | |
| 31 | export function base64StringtoFile(base64String, filename) { |
| 32 | let arr = base64String.split(","), |
| 33 | // type of uploaded image |
| 34 | mime = arr[0].match(/:(.*?);/)[1], |
| 35 | // decode base64 |
| 36 | bstr = atob(arr[1]), |
| 37 | n = bstr.length, |
| 38 | u8arr = new Uint8Array(n); |
| 39 | while (n--) { |
| 40 | u8arr[n] = bstr.charCodeAt(n); |
| 41 | } |
| 42 | const ext = mime.split("/").pop(); |
| 43 | const name = `${filename}.${ext}`; |
| 44 | return new File([u8arr], name, { type: mime }); |
| 45 | } |
| 46 | |
| 47 | function formatFixedDate(date = new Date()) { |
| 48 | const dd = String(date.getDate()).padStart(2, "0"); |