(file: File)
| 8 | * For large files (1GB+), this will take significant time |
| 9 | */ |
| 10 | const processFile = async (file: File): Promise<void> => |
| 11 | new Promise((resolve, reject) => { |
| 12 | const reader = new FileReader(); |
| 13 | |
| 14 | reader.onload = () => { |
| 15 | // File has been fully read into memory |
| 16 | resolve(); |
| 17 | }; |
| 18 | |
| 19 | reader.onerror = () => { |
| 20 | reject(new Error(`Failed to read file: ${file.name}`)); |
| 21 | }; |
| 22 | |
| 23 | reader.onabort = () => { |
| 24 | reject(new Error(`File reading was aborted: ${file.name}`)); |
| 25 | }; |
| 26 | |
| 27 | // Read the file as ArrayBuffer - this takes time for large files |
| 28 | // For a 1GB file, this can take several seconds |
| 29 | reader.readAsArrayBuffer(file); |
| 30 | }); |
| 31 | |
| 32 | /** |
| 33 | * Process an image file by reading its content |
no test coverage detected