React File Downloads to Rails

To continue on my quest to become the world’s best developer I’ve figured a developer should have two functionalities locked down. That being upload functionality as well as download functionality. If you missed my upload article, well… It’s right here. When it comes to downloads, It’s a lot less work overall, but it’s not entirely intuitive.

To start off, if you want an item to be downloaded on a click of a button all you really need to do is set up your <a> tag to look something like this:

const link = `http://localhost:3000/image_file/${id}`