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 8820391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:35:48+00:00 2026-06-14T05:35:48+00:00

Following the Ryan Bates tutorial on direct uploading to S3 using CarrierWave and background

  • 0

Following the Ryan Bates tutorial on direct uploading to S3 using CarrierWave and background jobs with Sidekiq.

I am seeing the following error in the background worker from the sidekiq log.

    2012-11-10T14:33:56Z 44401 TID-owd2xrzdg WARN: {"retry"=>true, "queue"=>"default", "class"=>"Article::ImageWorker", "args"=>[44, "uploads/d8850e90-0d6d-0130-fecf-3c0754129341/mkv5E.jpg"], "jid"=>"8add5079541725ad30550f9c", "error_message"=>"Validation failed: Image could not download file", "error_class"=>"ActiveRecord::RecordInvalid", "failed_at"=>"2012-11-10T14:29:15Z", "retry_count"=>4, "retried_at"=>2012-11-10 14:33:56 UTC}
    2012-11-10T14:33:56Z 44401 TID-owd2xrzdg WARN: Validation failed: Image could not download file
    2012-11-10T14:33:56Z 44401 TID-owd2xrzdg WARN: /Users/kgoddard/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.8/lib/active_record/validations.rb:56:in `save!'

Here is my Uploader

class ImageUploader < CarrierWave::Uploader::Base
  # Include CarrierWave direct uploader to background upload task.
  include CarrierWaveDirect::Uploader

  # Include RMagick or MiniMagick support:
  include CarrierWave::RMagick
  # include CarrierWave::MiniMagick

  # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
  include Sprockets::Helpers::RailsHelper
  include Sprockets::Helpers::IsolatedHelper

  # Choose what kind of storage to use for this uploader:
  # storage :file
  storage :fog

  # Set the mimetype of the upload incase it is incorrect.
  include CarrierWave::MimeTypes
  process :set_content_type

  process :resize_to_limit => [640, 640]

  version :thumb do
    process :resize_to_fill => [160, 120]
  end

end

The Article Model

class Article < ActiveRecord::Base
  attr_accessible :orientation, :shoot_id, :image
  belongs_to :shoot
  mount_uploader :image, ImageUploader

  after_save :enqueue_image

  def image_name
    File.basename(image.path || image.filename) if image
  end

  def enqueue_image
    ImageWorker.perform_async(id, key) if key.present?
  end

  class ImageWorker
    include Sidekiq::Worker

    def perform(id, key)
        article = Article.find(id)
        article.key = key
        article.remote_image_url = article.image.direct_fog_url(:with_path => true)
        article.save!
        article.update_column(:image_processed, true)
    end

  end

end

CarrierWave config

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',       # required
    :aws_access_key_id      => ENV["AWS_ACCESS_KEY_ID"],       # required
    :aws_secret_access_key  => ENV["AWS_SECRET_ACCESS_KEY"],       # required
    :region                 => 'eu-east-1'  # optional, defaults to 'us-east-1'
  }
  config.fog_directory  = ENV["AWS_S3_BUCKET"]                       # required
end

Shoot controller show action that is responsible for rendering the upload form

  # GET /shoots/1
  # GET /shoots/1.json
  def show
    # TODO: is this the best way to prevent users from accessing not owned resources.
    @shoot = Shoot.find(params[:id])
    @uploader = Article.new.image
    @uploader.success_action_redirect = new_admin_article_url    
    if @shoot
      respond_to do |format|
        format.html # show.html.erb
      end
    else
      redirect_to shoots_path, alert: 'No shoot found with id: #{params[:id]}'
    end
  end

Form for show action uploader

<div class="hero-unit">
  <h2><%= @shoot.name %></h2>
  <p><%= @shoot.overview %></p>
  <p>This shoot was taken on <%= @shoot.shoot_date %></p>
  <%= direct_upload_form_for @uploader do |f| %>
    <p><%= f.file_field :image, multiple: true, name: "article[image]" %></p>
    <p><%= f.submit "Add Media", :class => "btn btn-primary" %></p>
  <% end %>
</div><!-- /hero-unit -->
  • 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-14T05:35:49+00:00Added an answer on June 14, 2026 at 5:35 am

    Turns out my bucket name was invalid… Make sure that your bucket name only includes letters, numbers and dashes.

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

Sidebar

Related Questions

I am using Rails 3.2.5. Following Ryan Bates tutorial. http://railscasts.com/episodes/145-integrating-active-merchant . My order.rb has
I'm following along on Ryan Bates' excellent tutorial on using the built-in PostgresQL full-text
I'm trying to deploy to a VPS following Ryan Bates screencast. I'm using thin
I've been following through Ryan Bates' railscast on using cancan but am stumped as
I'm using jquery_token_input after following Ryan Bates railscast #258 and this is the code
I'm following along with Ryan Bates backbone.js tutorial for Rails. He uses jst.eco templating.
I am using nifty layout from Ryan Bates and that includes Layout helper with
I am following the tutorial http://railscasts.com/episodes/253-carrierwave-file-uploads?view=comments by ryan but he state that we must
I am following Ryan Bates's tutorial on Rails 3 ActionMailer . I generate the
I've been following Ryan Bates Railscast on Subdomains http://railscasts.com/episodes/221-subdomains-in-rails-3 and using lvh.me to serve

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.