Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Paperclip conflict between aws-s3 gem and right_aws gem. How to solve?

for a new App I want to use paperclip to store Files to S3. I already have installed the aws-s3 gem for another app. That seems to cause some problems, because Paperclip should use right_aws but is trying to use the aws-s3 gem. But I don't want to remove the aws-s3 gem from my system. Is there a way to solve this conflict? Maybe by forcing paperclip to use right_aws? Or by changing the configuration?

My setup

# enviroment.rb
config.gem 'right_aws'

# my model with the attachment
has_attached_file :thumbnail, 
    :styles => { :thumb => "160x120>" },
    :storage => :s3,
    :s3_credentials => "#{RAILS_ROOT}/config/amazons3.yml",
    :path => ":provider/:attachment/:id_:style.:extension"

# config/amazons3.yml
development:
  bucket: bucketname
  access_key_id: secret
  secret_access_key: secret

test:
  bucket: bucketname
  access_key_id: secret
  secret_access_key: secret

production:
  bucket: bucketname
  access_key_id: secret
  secret_access_key: secret

# The Error in the console
ArgumentError: wrong number of arguments (5 for 4)
    from /Library/Ruby/Gems/1.8/gems/right_http_connection-1.2.4/lib/net_fix.rb:85:in `send_request_with_body_stream'
    from /Library/Ruby/Gems/1.8/gems/right_http_connection-1.2.4/lib/net_fix.rb:85:in `exec'
    from /Library/Ruby/Gems/1.8/gems/right_http_connection-1.2.4/lib/net_fix.rb:144:in `request'
    from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/connection.rb:45:in `request'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:543:in `start'
    from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/connection.rb:52:in `request'
    from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:69:in `request'
    from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:88:in `put'
    from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/object.rb:241:in `store'
...

Thanks!

like image 326
Ole Spaarmann Avatar asked Oct 11 '09 13:10

Ole Spaarmann


2 Answers

Wow, that was fast. I solved the issue by just using the aws-s3 gem and therefore changing my enviroment.rb to read:

#config.gem 'right_aws'
config.gem "aws-s3", :version => ">= 0.6.2", :lib => "aws/s3"

Hope that helps somebody!

like image 105
Ole Spaarmann Avatar answered Oct 13 '22 01:10

Ole Spaarmann


Not long ago Amazon released official AWS SDK for Ruby. It works pretty well with S3, supports American, European and Japanese S3 instances from the box and well maintained.

I have created a storage module for Paperclip called paperclip-aws to works with AWS SDK.

Feel free to use it. I hope that it will help.

like image 30
Igor Alexandrov Avatar answered Oct 13 '22 01:10

Igor Alexandrov