File uploads
Last modified on Fri 24 Jul 2020

Our standard file upload setup includes:


There are several file upload gems out there. We use Shrine because of its flexibility and maintainability. It is a general-purpose file uploader gem. Since it has no direct dependency, it can be used in both Rails and non-Rails projects.

Official docs can be found here There is also a demo application.


Shrine features a rich plugin system which makes it incredibly easy to change its behavior to suit your needs.

Here are some of the plugins we use often:


Files stored on S3 are private by default. This means file URLs will be signed and they will expire after some specified time.

It's best to explicitly set the expiration time for each uploader class using url_options plugin.

Some files need to be public, i.e. albums' covers. In that case, set the acl to public-read via upload_options plugin for that uploader class.

Other guidelines

Direct S3 upload

Mobile or web front ends often upload files through the app server, which means that the file does a double hop: from the frontend to the backend, then from the backend to the cloud storage service.

Direct upload solves this double-hop performance problem by giving one-time credentials to the frontend app to upload files directly to the cloud, and it sends out references to those files to the backend.

This is extremely useful if you want to speed up the uploading process and improve user experience.

To implement direct S3 upload with Shrine, read the instructions here.

Accessing files on S3

To access files on s3, ask someone from the DevOps team for the S3 console access.