Active Storage direct upload progress with Stimulus

8782
0

Direct uploads are great because they keep file traffic away from your Rails dynos, but the default UX is opaque. I attach a Stimulus controller that listens for Active Storage’s direct-upload:* events and updates a progress bar. This keeps the markup server-rendered and the behavior reusable across forms. The controller can also disable submit until upload completes, which prevents a confusing “record saved but file missing” state. In a Turbo app, this plays nicely because the form is still submitted normally; the only enhancement is progress feedback. I also keep the progress UI inside a small wrapper so it’s easy to style with Tailwind.