Backend for AIintermediate11 min · 10 steps
File Uploads to Object Storage
Let clients upload straight to object storage with short-lived presigned URLs your API issues, then validate, scan and process the untrusted file asynchronously.
heavy workerrorrequestresponsedatasignal
ProblemStep 1 of 10
Uploads through the API, straight into the index
The naive design: the browser POSTs the file to the API, which holds the bytes, writes them to disk and indexes them immediately. Every 25 MB upload ties up an API worker for the whole transfer, on the same machines that serve chat.
And uploaded files are untrusted: they can carry malware, be enormous (a 2,000-page PDF), or hide prompt-injection text that the assistant will later retrieve and obey.
Watch outEvery uploaded file is attacker-controlled input until it has been scanned and verified.
Lesson 17 of 20 in Backend for AI