carrierwave S3 post-processing

169 views
Skip to first unread message

Nicolas de Moreau

unread,
Feb 2, 2012, 1:51:59 AM2/2/12
to carrierwave
Hello,

I'm using carrierwave with carrierwave_direct to upload directly to
S3. Everything works fine without post-processing but when I try to do
the post-processing, I get a 403 forbidden error when trying to
execute the code: self.remote_avatar_url =
avatar.direct_fog_url(:with_path => true)

My full code is:

config:

CarrierWave.configure do |config|
config.storage = :fog
config.fog_directory = S3_CREDENTIALS[:bucket]
config.fog_public = false

config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'xxx'
}
end

avatar_uploader.rb:

class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
include CarrierWaveDirect::Uploader
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}"
end
version :thumb do
process :resize_to_limit => [50, 50]
end
end

class ClipsController < ApplicationController
def index
if params[:key]
clip = Clip.new
clip.attachable_id = key[3]
clip.attachable_type = "Pmdocument"
clip.key = params[:key]
# clip.save
clip.save_and_process_avatar
end

class Clip < ActiveRecord::Base
def save_and_process_avatar(options = {})
if options[:now] or 1==1
self.remote_avatar_url = avatar.direct_fog_url(:with_path =>
true)
save
else
Resque.enqueue(AvatarProcessor, attributes)
end
en
end

I've been hanging with this for about one day now. So I really need
help... Thanks!

Hernán Orozco

unread,
Aug 24, 2013, 3:26:04 AM8/24/13
to carri...@googlegroups.com, nic...@demoreau.be
Hey the problem is that in your carrierwave initializer (config) you have this: 
    config.fog_public = false
This configuration is not allowing the image access, then you got a 403 forbidden error response. Remove the line or configure it with true.
     config.fog_public = true
Reply all
Reply to author
Forward
0 new messages