Reputation: 13
I have implemented paperclip in rails exactly as a variety of tutorials recommend. Upon trying to upload a photo I consistently get the following:
AWS::S3::NoConnectionEstablished
usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/connection.rb:213:in `connection'
/usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:69:in `request'
/usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/base.rb:88:in `put'
/usr/local/lib/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/object.rb:241:in `store'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip/storage.rb:195:in `flush_writes'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip/storage.rb:192:in `each'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip/storage.rb:192:in `flush_writes'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip/attachment.rb:142:in `save'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip.rb:331:in `send'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip.rb:331:in `save_attached_files'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip.rb:324:in `each_attachment'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip.rb:323:in `each'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip.rb:323:in `each_attachment'
/Users/joshcutler/code/NiteMob/vendor/plugins/paperclip/lib/paperclip.rb:330:in `save_attached_files'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:178:in `send'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:178:in `evaluate_method'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:166:in `call'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:93:in `run'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:92:in `each'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:92:in `send'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:92:in `run'
/Users/joshcutler/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:276:in `run_callbacks'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:344:in `callback'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:251:in `create_or_update'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2539:in `save_without_validation'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:1009:in `save_without_dirty'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/dirty.rb:79:in `save_without_transactions'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:229:in `send'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:182:in `transaction'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:196:in `save'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:196:in `save'
/Users/joshcutler/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2628:in `update_attributes'
here is my model declaration:
attr_accessor :image_file_name
has_attached_file :image,
:styles => { :medium => "300x300>", :thumb => "100x100>" },
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:s3_headers => {"Expires" => 1.year.from_now.httpdate},
:path => ":attachment/:id/:style/:basename.:extension",
:bucket => "something_unique"
Here is the format of my s3.yml:
development:
access_key_id: "my_key"
secret_access_key: "my_secret_key"
production:
access_key_id: "my_key"
secret_access_key: "my_secret_key"
Any ideas what is going on?
Thanks!
Upvotes: 1
Views: 2205
Reputation: 16287
To help debug, try taking paperclip out of the equation and accessing Amazon S3 directly from Ruby. You can do this using the s3sh
command which opens IRB and loads up the aws-s3 gem. Run s3sh
in your command line and try typing the following.
# connect to S3 using your credentials
AWS::S3::Base.establish_connection!(
:access_key_id => 'my_key',
:secret_access_key => 'my_secret_key'
)
# Store an image on S3
S3Object.store("foo.jpg", open("path/to/foo.jpg"), "something_unique")
# See if it's on there
bucket = Bucket.find("something_unique")
bucket["foo.jpg"]
You can find more information about the aws-s3 gem here.
Upvotes: 8