There’s some things that every web application needs, and some they don’t need very often. File uploads are closer to the first category than the second; thinking back, most of my apps needed to upload files. If you need to upload big files, it’s kind of a problem: if you’re building a twelve-factor style app on something like Heroku, your web workers should have pretty short timeouts, since most of your requests are served quickly. But your file uploads take a long time. What to do?

Enter s3_multipart. From the README:

The S3 Multipart gem brings direct multipart uploading to S3 to Rails. Data is piped from the client straight to Amazon S3 and a server-side callback is run when the upload is complete.

Multipart uploading allows files to be split into many chunks and uploaded in parallel or succession (or both). This can result in dramatically increased upload speeds for the client and allows for the pausing and resuming of uploads.

Neat, eh? The README has more details of how to use the gem. It’s a bit complex: you need to set up CORS on your S3 bucket, run some generators, write some JavaScript.

The gem is still young, and looking for contributions. This is a tough problem, and having an easy way to solve it is great!


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.