我已经在轨道中实现了回形针,正如各种教程所推荐的那样.在尝试上传照片时,我始终如一地获得以下内容:
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'
这是我的模型声明:
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"
这是我的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"
有什么想法发生了什么?
谢谢!
为了帮助调试,请尝试将paperclip从等式中取出并直接从Ruby访问Amazon S3.您可以使用s3sh
打开IRB 的命令并加载aws-s3 gem 来执行此操作.s3sh
在命令行中运行并尝试键入以下内容.
# 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"]
您可以在此处找到有关aws-s3 gem的更多信息.