I'm looking for the best ways to upload a file in a Rails app on Heroku. Setup: Rails 3, Carrierwave, Heroku, Mongoid
Problem: Sporadically, when a user uploads a file of varying sizes, the image is saved to the database, but not available in any form on Amazon S3. This results in the image displaying as a missing image placeholder on the front end.
Probable Cause: Image is uploaded but processing is too time consuming and the request times out due to Heroku's hard 30 second request time limit, or image size is too large and in attempting to upload, the request times out with H12 error.
Solution: Implement carrierwave-direct and move processing to background
Blocker: CarrierWaveDirect is not a drop in replacement for CarrierWave. In fact, it introduces some major changes in the process of uploading an image, notably the image is not uploaded at the same time of db record persistence. Also, it does not work with my existing directory structure, so moving my existing files to a new structure seems overly arduous. CarrierWaveBackgrounder does not play nice with embedded documents.
Question: How do I do this? Example code if needed, but trying to think through this moreso than just coding it.