Commit d2f2197
committed
fix: image commits leads to invalid images
**Location:** `src/blob.ts`, line 28
The code was reading files with UTF-8 text encoding:
```typescript
fs.createReadStream(this.absolutePath, { encoding: 'utf8' })
```
Images are **binary files** containing arbitrary byte values (0-255). The UTF-8 encoding option tells Node.js to:
1. Interpret the binary data as UTF-8 text
2. Drop any byte sequences that are not valid UTF-8
This causes data loss because:
- Valid UTF-8 sequences are 1-4 bytes depending on the character
- Many byte combinations in binary files are invalid UTF-8 sequences
- These invalid bytes are silently dropped by the UTF-8 decoder
- The resulting file is corrupted (missing bytes)1 parent d76880d commit d2f2197
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | | - | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
0 commit comments