Using the JQuery Bootstrap Branch with S3 for Photo storage

131 views
Skip to first unread message

Martin Düren

unread,
Mar 19, 2013, 6:49:45 AM3/19/13
to communi...@googlegroups.com
Hello,

i got my rails application using CE up and running now, but somehow I can't make the image uploads work. 

In the standard installation I would always get this error when I try to upload an image: 

Photo /tmp/stream20130319-18602-13k89ab.gif is not recognized by the 'identify' command.

Imagemagick is correctly installed and the identify-command works. The permissions to the /tmp/ folder are correct, too. So I am clueless with this issue =(.

To work around this issue I tried to use Amazon S3 for storage since I don't mind where the images come from. I copied the correctly filled out s3.yml to the applications /config/ folder. I am using gem "aws-sdk" in my Gemfile as suggested here: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/storage/s3.rb; and I updated application_config.rb like this:

:photo => {
    :missing_thumb => '/assets/icon_missing_thumb.gif',
    :missing_medium => "/assets/icon_missing_medium.gif",
    :paperclip_options => {
      :storage => 's3',
      :styles => {
        :thumb => {
          :geometry => '100x66#',
          :processors => [:cropper]
        },
        :medium => {
          :geometry => '300x200#',
          :processors => [:cropper]
        },
        :large => {
          :geometry => '600x400#',
          :processors => [:cropper]
        },   
        :original => "1024>"       
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']          
    }
  },
  
  :feature => {
    :use_thumbs => true,
    :paperclip_options => {
      :storage => 's3',
      :styles => {
        :thumb => "100x66#",
        :medium => '300x200#',
        :large => "600x400#",
        :original => '1024>'             
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']          
    }
  },
  
  :clipping => {
    :paperclip_options => {
      :storage => 's3',
      :styles => {
        :thumb => "100x66#",
        :medium => "300x200#",
        :large => "600x400#",
        :original => '1024>'     
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']              
    }
  },


When I try to edit a user profile or upload an image I get this error: 
uninitialized constant AWS::S3::Base
Full Trace here:

 paperclip (2.4.5) lib/paperclip/storage/s3.rb:101:in `block in extended'
paperclip (2.4.5) lib/paperclip/storage/s3.rb:79:in `instance_eval'
paperclip (2.4.5) lib/paperclip/storage/s3.rb:79:in `extended'
paperclip (2.4.5) lib/paperclip/attachment.rb:392:in `extend'
paperclip (2.4.5) lib/paperclip/attachment.rb:392:in `initialize_storage'
paperclip (2.4.5) lib/paperclip/attachment.rb:73:in `initialize'
paperclip (2.4.5) lib/paperclip.rb:448:in `new'
paperclip (2.4.5) lib/paperclip.rb:448:in `attachment_for'
paperclip (2.4.5) lib/paperclip.rb:337:in `block in has_attached_file'
activerecord (3.2.11) lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
activerecord (3.2.11) lib/active_record/attribute_assignment.rb:78:in `each'
activerecord (3.2.11) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.11) lib/active_record/base.rb:497:in `initialize'
/home/martin/.bundler/ruby/1.9.1/communityengine-281d49916dbc/app/controllers/photos_controller.rb:104:in `new'
/home/martin/.bundler/ruby/1.9.1/communityengine-281d49916dbc/app/controllers/photos_controller.rb:104:in `create'
actionpack (3.2.11) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.11) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.11) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.11) lib/active_support/callbacks.rb:460:in `block (2 levels) in _run__141873283__process_action__116704501__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_1705'
activesupport (3.2.11) lib/active_support/callbacks.rb:326:in `around'
activesupport (3.2.11) lib/active_support/callbacks.rb:310:in `_callback_around_1685'
activesupport (3.2.11) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_1705'
activesupport (3.2.11) lib/active_support/callbacks.rb:459:in `block in _run__141873283__process_action__116704501__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_1704'
/home/martin/.bundler/ruby/1.9.1/communityengine-281d49916dbc/lib/community_engine/localized_application.rb:25:in `set_locale'
activesupport (3.2.11) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_1704'
activesupport (3.2.11) lib/active_support/callbacks.rb:414:in `_run__141873283__process_action__116704501__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.11) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.11) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.11) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.11) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.11) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.11) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.11) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.11) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.11) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.11) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.11) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.11) lib/action_dispatch/routing/route_set.rb:601:in `call'
rakismet (1.3.0) lib/rakismet/middleware.rb:10:in `call'
omniauth (1.1.2) lib/omniauth/strategy.rb:177:in `call!'
omniauth (1.1.2) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.2) lib/omniauth/builder.rb:48:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.11) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__284061703__call__288038654__callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.11) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.11) lib/rails/engine.rb:479:in `call'
railties (3.2.11) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.11) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Can anyone help me here? I am really stuck with this.

Cheers
Martin

John Feras

unread,
Mar 19, 2013, 7:00:47 AM3/19/13
to communi...@googlegroups.com
Hi Martin...

Not sure if this is the cause, but I don't see a specification of the location of your credentials file (s3.yml) for s3 storage.. something like this in your application_config.rb:

      :storage => 's3',
      :s3_credentials => Rails.root.join('config', 's3.yml')
 


--
You received this message because you are subscribed to the Google Groups "CommunityEngine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to communityengi...@googlegroups.com.
To post to this group, send email to communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/communityengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Martin Düren

unread,
Mar 19, 2013, 3:07:15 PM3/19/13
to communi...@googlegroups.com, jfe...@ferasinfotech.com
Hm I added this, but now I am back at "Avatar photo /tmp/stream20130319-4076-6ohqme.jpg is not recognized by the 'identify' command." I think there must be something else wrong at the server. Here is an excerpt from the logs of where I think the problem is:

Started GET "/assets/tinymce/plugins/curblyadvimage/editor_plugin.js?3.5.8" for 127.0.0.1 at 2013-03-19 20:02:14 +0100
Served asset /tinymce/plugins/curblyadvimage/editor_plugin.js - 304 Not Modified (3ms)
[2013-03-19 20:02:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true


Started GET "/assets/tinymce/plugins/curblyadvimage/langs/en.js?3.5.8" for 127.0.0.1 at 2013-03-19 20:02:14 +0100
Served asset /tinymce/plugins/curblyadvimage/langs/en.js - 304 Not Modified (9ms)
[2013-03-19 20:02:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2013-03-19 20:02:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2013-03-19 20:02:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2013-03-19 20:02:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2013-03-19 20:02:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
identify.im6: unable to open image `file': No such file or directory @ error/blob.c/OpenBlob/2638.
identify.im6: no decode delegate for this image format `file' @ error/constitute.c/ReadImage/544.
identify.im6: unable to open image `file': No such file or directory @ error/blob.c/OpenBlob/2638.
identify.im6: no decode delegate for this image format `file' @ error/constitute.c/ReadImage/544.
identify.im6: unable to open image `file': No such file or directory @ error/blob.c/OpenBlob/2638.
identify.im6: no decode delegate for this image format `file' @ error/constitute.c/ReadImage/544.
identify.im6: unable to open image `file': No such file or directory @ error/blob.c/OpenBlob/2638.
identify.im6: no decode delegate for this image format `file' @ error/constitute.c/ReadImage/544.


Started PUT "/users/martins3" for 127.0.0.1 at 2013-03-19 20:02:21 +0100
Processing by UsersController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"fFtNRbQYf0+TX72t21vJYb9DlfAVe43RyiqIPxzP8eo=", "user"=>{"avatar_attributes"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0xb6d09d8 @original_filename="south_park_avatar_by_kimmi092-d49cfkx.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[avatar_attributes][photo]\"; filename=\"south_park_avatar_by_kimmi092-d49cfkx.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20130319-4076-g6okmm>>}, "zip"=>"", "birthday(1i)"=>"1988", "birthday(2i)"=>"3", "birthday(3i)"=>"19", "description"=>"", "tag_list"=>""}, "country_id"=>"", "commit"=>"Save Changes", "id"=>"martins3"}
[I18n] loading locale: en from config
[I18n] Locale set to en
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
   (0.0ms)  begin transaction
  Slug Load (0.1ms)  SELECT "slugs".* FROM "slugs" WHERE "slugs"."sluggable_id" = 3 AND "slugs"."sluggable_type" = 'User' ORDER BY id DESC LIMIT 1
  CACHE (0.0ms)  SELECT "slugs".* FROM "slugs" WHERE "slugs"."sluggable_id" = 3 AND "slugs"."sluggable_type" = 'User' ORDER BY id DESC LIMIT 1
   (0.2ms)  UPDATE "users" SET "last_request_at" = '2013-03-19 19:02:21.369452', "perishable_token" = 'J2qwvJM11avWOz5mBb0X', "updated_at" = '2013-03-19 19:02:21.371400' WHERE "users"."id" = 3
  Slug Load (0.1ms)  SELECT "slugs".* FROM "slugs" WHERE "slugs"."sluggable_id" = 3 AND "slugs"."sluggable_type" = 'User' ORDER BY id DESC LIMIT 1
  ActsAsTaggableOn::Tag Load (0.1ms)  SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = 3 AND "taggings"."taggable_type" = 'User' AND (taggings.context = 'tags')
  CACHE (0.0ms)  SELECT "slugs".* FROM "slugs" WHERE "slugs"."sluggable_id" = 3 AND "slugs"."sluggable_type" = 'User' ORDER BY id DESC LIMIT 1
  CACHE (0.0ms)  SELECT "slugs".* FROM "slugs" WHERE "slugs"."sluggable_id" = 3 AND "slugs"."sluggable_type" = 'User' ORDER BY id DESC LIMIT 1
   (57.4ms)  commit transaction
  User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."login_slug" = 'martins3' AND (users.activated_at IS NOT NULL) LIMIT 1
   (0.1ms)  begin transaction
Command :: identify -format %wx%h :file
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream20130319-4076-6ohqme.jpg is not recognized by the 'identify' command.>
Command :: identify -format %wx%h :file
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream20130319-4076-6ohqme.jpg is not recognized by the 'identify' command.>
Command :: identify -format %wx%h :file
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream20130319-4076-6ohqme.jpg is not recognized by the 'identify' command.>
Command :: identify -format %wx%h :file
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream20130319-4076-6ohqme.jpg is not recognized by the 'identify' command.>
   (0.0ms)  SELECT COUNT(*) FROM "authorizations" WHERE "authorizations"."user_id" = 3

Maybe I need to specify the path to the uploaded images somewhere?

John Feras

unread,
Mar 20, 2013, 10:51:12 AM3/20/13
to Martin Düren, communi...@googlegroups.com
Hi Martin...

In your s3.yml, do you have 'bucket_name' or 'bucket' ?

I think in an older version, 'bucket_name' was used, but in the more recent versions, it now wants 'bucket'.

Hope this is helpful....

John


On Wed, Mar 20, 2013 at 10:44 AM, Martin Düren <martin...@googlemail.com> wrote:
Hi,

I see those errors both on my production server as well as in development; but I think I resolved the issue by upgrading to paperclip 2.7.4. At least now the 'identify'-command error is gone. Now I get a "ArgumentError (missing required :bucket option):"-Error: 

################ production.log ########################
Command :: identify -format %wx%h '/tmp/stream20130320-15755-45tiv320130320-15755-ejk9ju[0]'
Command :: convert '/tmp/stream20130320-15755-45tiv320130320-15755-ejk9ju[0]' -resize "600x" -crop "600x400+0+198" +repage '/tmp/stream20130320-15755-45tiv320130320-15755-ejk9ju20130320-15755-1x3r2u3'
[paperclip] Saving attachments.
[paperclip] saving /photos/15/original/southpark_adam.gif
Command :: file -b --mime '/tmp/stream20130320-15755-45tiv320130320-15755-ejk9ju'
Completed 500 Internal Server Error in 1663ms

ArgumentError (missing required :bucket option):
  paperclip (2.7.4) lib/paperclip/storage/s3.rb:165:in `bucket_name'
  paperclip (2.7.4) lib/paperclip/storage/s3.rb:193:in `s3_bucket'
  paperclip (2.7.4) lib/paperclip/storage/s3.rb:197:in `s3_object'
  paperclip (2.7.4) lib/paperclip/storage/s3.rb:295:in `block in flush_writes'
  paperclip (2.7.4) lib/paperclip/storage/s3.rb:281:in `each'
  paperclip (2.7.4) lib/paperclip/storage/s3.rb:281:in `flush_writes'
  paperclip (2.7.4) lib/paperclip/attachment.rb:216:in `save'
  paperclip (2.7.4) lib/paperclip.rb:472:in `block in save_attached_files'
  paperclip (2.7.4) lib/paperclip.rb:465:in `block in each_attachment'
  paperclip (2.7.4) lib/paperclip.rb:464:in `each'
  paperclip (2.7.4) lib/paperclip.rb:464:in `each_attachment'
  paperclip (2.7.4) lib/paperclip.rb:471:in `save_attached_files'

################ production.log ########################

As you can see in the log the identify command works now with the newer paperclip version. Do you know how to properly give the S3 options? for now this is my application_config.rb:

############################ application_config.rb #####################################
:photo => {
    :missing_thumb => '/assets/icon_missing_thumb.gif',
    :missing_medium => "/assets/icon_missing_medium.gif",
    :paperclip_options => {
      :storage => 's3',
      :s3_credentials => Rails.root.join('config', 's3.yml'),
      :styles => {
        :thumb => {
          :geometry => '100x66#',
          :processors => [:cropper]
        },
        :medium => {
          :geometry => '300x200#',
          :processors => [:cropper]
        },
        :large => {
          :geometry => '600x400#',
          :processors => [:cropper]
        },   
        :original => "1024>"       
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']          
    }
  },
  
  :feature => {
    :use_thumbs => true,
    :paperclip_options => {
      :storage => 's3',
      :s3_credentials => Rails.root.join('config', 's3.yml'),
      :styles => {
        :thumb => "100x66#",
        :medium => '300x200#',
        :large => "600x400#",
        :original => '1024>'             
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']          
    }
  },
  
  :clipping => {
    :paperclip_options => {
      :storage => 's3',
      :s3_credentials => Rails.root.join('config', 's3.yml'),
      :styles => {
        :thumb => "100x66#",
        :medium => "300x200#",
        :large => "600x400#",
        :original => '1024>'     
      }
    },
    :validation_options => {
      :max_size => 3,
      :content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']              
    }
  },
############################ application_config.rb #####################################


And this is my s3.yml:

############################ s3.yml #####################################
development:
  bucket_name: xxx
  access_key_id: 'xxx'
  secret_access_key: 'xxx'
  use_persistent: true

test:
  bucket_name: xxx
  access_key_id: 'xxx'
  secret_access_key: 'xxx'
  use_persistent: false

production:
  bucket_name: xxx
  access_key_id: 'xxx'
  secret_access_key: 'xxx'
  use_persistent: false
############################ s3.yml #####################################




On Tue, Mar 19, 2013 at 8:20 PM, John Feras <jfe...@ferasinfotech.com> wrote:
Hi Martin...

I know I had a similar issue on my development platform (macbook) when running an older version of ImageMagick, which was resolved after upgrade.
These errors you're seeing are on your production server?
Reply all
Reply to author
Forward
0 new messages