Rails The context of the paper clip between aws-s3 and right_aws gems. How to solve?

for a new application. I want to use paperclip to store files on S3. I have already installed the aws-s3 gem for another application. This seems to cause some problems because Paperclip should use right_aws, but is trying to use the aws-s3 gem. But I do not want to remove the aws-s3 gem from my system. Is there any way to resolve this conflict? Maybe forcing a paper clip to use the right? Or by changing the configuration?

My setting

# 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!

+6
ruby-on-rails amazon-s3 paperclip right-aws
source share
4 answers

Wow, that was fast. I solved the problem simply by using the aws-s3 gem and therefore changing my enviroment.rb as follows:

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

Hope someone helps!

+12
source share

Amazon recently released the official AWS SDK for Ruby . It works great with S3, supports American, European and Japanese S3 instances out of the box and is neat and tidy.

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

Feel free to use it. I hope this helps.

+4
source share

I also had this problem. Specifying gems in a specific order seems to work for some people:

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

In my application, I also had a plugin (backup_fu) indicating right_aws , and I also had to comment out a line in my plugin:

 # backup_fu.rb require 'yaml' require 'active_support' require 'mime/types' require 'right_aws' unless defined?(RightAws) require 'erb' class BackupFuConfigError < StandardError; end class S3ConnectError < StandardError; end class BackupFu # etc... end 

Does anyone know why this is a problem?

EDIT: In my application, I no longer require rights to everything, and then in the backup_fu file I changed the require line to require only right_aws if it is not already loaded. I found that by requiring a gem in environment.rb, it caused a conflict with the aws-s3 gem. So, now the backup_fu plugin will load it if necessary (usually only when starting as a rake task), but not when starting the application.

+3
source share

The main problem here is that aws-s3 overrides a method called send_request_with_body_stream .

The aws-s3 version has 4 arguments, and the right_http_connection is 5. The aws-s3 version may override the version of this method in the right_http_connection depending on the download order.

I cloned right_http_connection and quickly fixed this problem. I sent a transfer request right_http_connection.

Therefore, you can use the git repository in your kit to fix this problem:

gem 'right_http_connection', :git => "git://github.com/gammons/right_http_connection"

+3
source share

All Articles