Secure File Uploads in Node.js with Cloud Storage

Secure File Uploads in Node.js with Cloud Storage

Presigned URLs, validation and private buckets: uploads that do not overload your server or expose your files.

Streaming large files through your API server wastes memory and bandwidth. Uploading directly to cloud storage with presigned URLs is simpler and safer.

The presigned URL flow

  1. The client asks your API for an upload URL, sending the file name, type and size.
  2. Your API validates the request and returns a short-lived presigned URL for a specific key.
  3. The client uploads directly to storage.
  4. The client tells your API the upload finished, and the API records it.

Validate before signing

  • Allow-list content types, such as image/png and application/pdf.
  • Enforce a maximum size in the signed policy, not only in the UI.
  • Generate the storage key on the server; never trust a client-supplied path.

Keep buckets private

Store uploads in a private bucket and serve them through short-lived signed download URLs or a CDN with access rules. Public buckets are one of the most common sources of data leaks.

Process after upload

Resize images, scan files and extract metadata in a background job triggered after the upload is confirmed. The user gets a fast response and heavy work happens off the request path.

More on this topic

Photography
3D Models
Development
Illustrations
Fashion
Digital Art
Packaging
Motion
Illustrations
Video Production
Photography
3D Models
Development
Illustrations
Fashion