# Base64 Data URI & Binary Restore: Production Encoding Pitfalls

> **TL;DR**: A senior engineer's deep dive into Base64 encoding mechanics, Data URI RFC 2397 limits, streaming decode, and production failure modes when restoring binary files.
> **Source**: https://ai.yevrix.com/articles/base64-data-uri-binary-restore-production-guide

## 1. The Real Incident: How Base64 Took Down a Service

At 2 AM, an internal admin portal's "export attachment" endpoint started returning 502s. Nginx logged `upstream prematurely closed connection`, and the Python worker had been killed by the OOM killer. Root cause: an operator uploaded a 180MB PDF, and the backend did `base64.b64encode(f.read())` — reading the entire file into memory, then embedding the result in a JSON response. Ba

...

> Full engineering guide unlocked at https://ai.yevrix.com/articles/base64-data-uri-binary-restore-production-guide
