Brief Background I have a Rails web application that allows users to upload an avatar and audio files. The app stores, retrieves, and displays/plays this media back to the user once it is uploaded. The web app is hosted on Amazon Elastic Beanstalk, and I’m using Rails ActiveStorage to store the uploaded files to Amazon S3. I’m using a Postgres Amazon RDS database generated through my Elastic Beanstalk instance to handle all other (non-media) storage.
Problem In production, a user can upload image and audio files to S3 using the web app, but calling the ActiveStorage
service_url method to retrieve these files from S3 only works for images (no URL is found/generated for successfully uploaded audio files, even though ActiveStorage was used to upload the files to S3).
What I’ve Tried I’ve pointed my dev environment to S3 to see if audio upload and retrieval works when I run the server locally, and it works perfectly! A user is able to upload an audio file to S3 and retrieve that file from S3 using the ActiveStorage
service_url method. With this change, my dev and production configurations are almost identical, so I’m wondering if there’s some extra configuration I need to do for Beanstalk, S3 or maybe even Nginx to make ActiveStorage work for retrieving audio stored in S3 in production?