file-uploads

Hardening file uploads with MIME checks and storage isolation

File uploads are attacker-controlled input with extra surface area. I validate extension and MIME type, rename everything server side, scan risky formats, and keep user uploads out of executable paths. If the business allows arbitrary uploads, storage

ActiveStorage for file uploads

ActiveStorage provides a unified interface for uploading files to cloud storage services like S3, GCS, or Azure Storage. I configure storage services in config/storage.yml and attach files to models using has_one_attached or has_many_attached macros.

Stimulus controller for drag-and-drop file uploads

Modern file uploads should support drag-and-drop in addition to traditional file inputs. I use Stimulus to handle dragover, drop, and paste events, showing upload previews and progress. The controller prevents default browser behavior for drag events