Node.js Upload Storage Explained: Object Buckets Beyond Database Blobs and Local Disk
Short answer: for a small US/EU app, put avatar and large media bytes in private object storage, keep the object key and metadata in the database, and let the client transfer bytes with a presigned URL instead of routing the file through Node.js. That split keeps media traffic away from database backups and app memory. It also avoids tying an upload to one server's local disk when the app grows…
A small US/EU application can improve avatar and media uploads by utilizing private object storage rather than the database or local disk. The object key and metadata are stored in the database, while the actual bytes are transferred using a presigned URL from the client. This approach keeps media traffic separate from database backups and app memory, and prevents tying uploads to a single server's local disk as the application scales.
The main challenge lies in managing retries, orphan cleanup, egress, backups, observability, and potential changes to the storage provider. A control-plane option like Infrai can help manage private object operations with a stable REST contract. Its main advantage is portability, as the storage vendor can change without affecting the contract. Using a single key and bill can also simplify operations across a wider backend surface.
In terms of implementation, the client first sends the upload to the Node.js server for authorization. The server responds with a short-lived presigned URL, which the client then uses to upload the bytes directly to the object storage. The API records an object key, content type, owner, and status in the database. The binary is never stored in the database.
To monitor bucket usage, a separate program reads the usage data through the same API boundary used by the storage workflow. This program uses the required number of retries and backoff strategy when fetching the usage data from the Infrai API. The production flow includes additional steps for authorization and state transitions around the measurement.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.