Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:38:37+00:00 2026-06-12T08:38:37+00:00

I’m looking for the best ways to upload a file in a Rails app

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:38:38+00:00Added an answer on June 12, 2026 at 8:38 am

    If you need to handle single files, check out this Railscast which covers CarrierWaveDirect and uploading to S3 in depth. Combined with the carrierwave-mongoid gem, you should be able to get single file uploads running if you want to go that route.

    Honestly though, I’d just go for multiple file upload and be done with it. In the second part he shows off a multi-file upload setup using standard Carrierwave and jQuery File Upload instead of CarrierWaveDirect. I tend to agree with that decision. I just couldn’t get it working right, most likely because of all the black magic required to POST directly to S3.

    Ryan’s setup looks intimidating at first, but it’s pretty simple, and in the source code for the episode he includes a helper class that takes care of all that form data funny business S3 requires.

    The basic workflow is something like:

    1) File gets uploaded directly from browser to temporary bucket or folder on S3 through jQuery plugin.

    2) AJAX POST request with the temp upload URL goes to app telling it to persist in the database and start a worker process.

    3) Worker process downloads temporary file, runs it through your CarrierWave setup and stores the finished versions in the right place.

    I think he uses sidekiq for the background jobs, but I have something similar set up with IronWorker and it works beautifully. Once you have the jQuery stuff and CarrierWave set up, you can use whatever you want for the jobs really.

    Also, in the comments there I explained how I take care of deleting the raw upload files from the temp bucket as part of the job to keep things tidy. And for all the dirty details on how POSTing straight to S3 works see here. Still a good idea to understand that even if you have the helper class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.