···268268 // Allow up to 100MB per file blob, with 2 minute timeout
269269 let content = await safeFetchBlob(blobUrl, { maxSize: 100 * 1024 * 1024, timeout: 120000 });
270270271271- // If content is base64-encoded, decode it back to gzipped binary
272272- if (base64 && encoding === 'gzip') {
273273- // Convert Uint8Array to Buffer for proper string conversion
271271+ // If content is base64-encoded, decode it back to binary (gzipped or not)
272272+ if (base64) {
273273+ // The content from the blob is base64 text, decode it directly to binary
274274 const buffer = Buffer.from(content);
275275- const base64String = buffer.toString('utf-8');
275275+ const base64String = buffer.toString('ascii'); // Use ascii for base64 text, not utf-8
276276 content = Buffer.from(base64String, 'base64');
277277 }
278278