Menu

How to Upload User Avatars with Node.js and Store Metadata in S3-Compatible Storage
📰

How to Upload User Avatars with Node.js and Store Metadata in S3-Compatible Storage

DEV Community: backend·VespasianBlack3884·7 days ago
#IsLqstvK
#devtobackend#devto#dev#object#tenant
Reading 0:00
15s threshold

Short answer: keep tenant isolation in the application, keep avatar objects private, and make storage a replaceable contract. The database should own the tenant, object key, content type, and validation result. Object storage should hold bytes and metadata. A worker should own expensive processing.

Keep it private.

For a healthtech product, that separation matters more than whether the first bucket is S3-compatible. A profile photo is personal data, and an overwrite can attach one patient's image to another patient's account. Generate keys from a server-side tenant and user identifier, never from a browser filename; validate before writing; write private objects; and persist the generated key only after the object write succeeds.

What does tenant isolation require from an avatar upload?

The upload endpoint should authenticate the caller, resolve the tenant from the session, check the byte limit and decoded image format, and choose the object key itself.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.