If you upload large files to S3 via Heroku, you cannot reasonably avoid timeouts. If someone decides to upload a large file, he will go into timeout. If it takes more than 30 seconds to download to Heroku, go to S3 and process the request, the timeout will expire. For a good reason, a 30s request is just crappy performance.
This blog post (and github repo) is very useful: http://pjambet.imtqy.com/blog/direct-upload-to-s3/
With it, you can work with files with direct access to s3. You completely avoid getting Heroku to the main part of the download. Using jquery-fileupload callbacks, you can send a message to the application after the file has been successfully downloaded and process it in the background using delayed_job. Confirming users a successful download is an application issue that you just need to take care of.
source share