1

我正在使用 Paperclip 升级我的 rails 应用程序并通过 ftp 上传我的附件(使用 paperclipftp gem)。我目前在我的开发环境中,其中包括 Rails 3.1.1、Ruby ruby​​ 1.9.2p290、回形针 3.0.4、aws-sdk 1.8.1.2 我对我的应用程序进行了更改以利用 aws-sdk gem 来利用 amazon s3 用于我的附件存储。这是我的 Gemfile 中的内容:

gem 'mysql2'
gem 'execjs'
gem 'web-app-theme', '~> 0.8.0'
gem 'therubyracer', :platforms => :ruby
gem 'paperclip', '~> 3.0.0'
gem 'tinymce-rails'
gem 'cocaine', '~> 0.3.2'
gem 'aws-sdk'

在我的模型中,我定义了附件:

#paperclip
  has_attached_file :upload,
     :styles => Proc.new { |attach| attach.instance.attachment_styles },
     :storage => :s3,
     :s3_credentials => Rails.root.join('config', 's3.yml'),
     :path => "/:attachment/:id/:style/:basename.:extension",
     :url => "http://" + FTP_CONFIG['file_host'] + "/:attachment/:id/:style/:basename.:extension"

我的 s3.yml 文件如下所示:

development:
  bucket: a36-dev
  access_key_id: #########
  secret_access_key: ##########

test:
  bucket: a36-test
  access_key_id: #########
  secret_access_key: #########

production:
  bucket: a36-prod
  access_key_id: #########
  secret_access_key: #########

我继续得到的错误是: MediaController#create_for_content 中的 Errno::ECONNABORTED 已建立的连接被主机中的软件中止

这是堆栈跟踪:

C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/openssl/buffering.rb:235:in `syswrite'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/openssl/buffering.rb:235:in `do_write'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/openssl/buffering.rb:249:in `write'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/protocol.rb:191:in `write0'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/protocol.rb:167:in `block in write'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/protocol.rb:182:in `writing'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/protocol.rb:166:in `write'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:1756:in `send_request_with_body_stream'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:1726:in `exec'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:1189:in `transport_request'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:1177:in `request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/net/http/connection_pool/session.rb:64:in `request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/net/http/connection_pool.rb:173:in `block in request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/net/http/connection_pool.rb:194:in `session_for'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/net/http/connection_pool.rb:171:in `request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/net/http/connection_pool/connection.rb:173:in `request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/http/net_http_handler.rb:66:in `handle'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:230:in `block in make_sync_request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:266:in `retry_server_errors'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:226:in `make_sync_request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:451:in `block (2 levels) in client_request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:334:in `log_client_request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:420:in `block in client_request'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:316:in `return_or_raise'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/core/client.rb:419:in `client_request'
(eval):3:in `put_object'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/s3/s3_object.rb:1649:in `write_with_put_object'
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.1.2/lib/aws/s3/s3_object.rb:600:in `write'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/storage/s3.rb:313:in `block in flush_writes'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/storage/s3.rb:299:in `each'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/storage/s3.rb:299:in `flush_writes'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/attachment.rb:200:in `save'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/instance_methods.rb:17:in `block in save_attached_files'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/instance_methods.rb:10:in `block in each_attachment'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/instance_methods.rb:9:in `each'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/instance_methods.rb:9:in `each_attachment'
vendor/bundle/ruby/1.9.1/gems/paperclip-3.0.4/lib/paperclip/instance_methods.rb:16:in `save_attached_files'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:401:in `_run_save_callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/callbacks.rb:264:in `create_or_update'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/persistence.rb:37:in `save'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/validations.rb:50:in `save'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/attribute_methods/dirty.rb:22:in `save'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:208:in `transaction'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:241:in `block in save'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/transactions.rb:240:in `save'
app/controllers/media_controller.rb:207:in `create_for_content'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/base.rb:167:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:425:in `_run__690981913__process_action__778841897__callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/callbacks.rb:17:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/rescue.rb:17:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `block in instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/base.rb:121:in `process'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/abstract_controller/rendering.rb:45:in `process'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal.rb:193:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_controller/metal.rb:236:in `block in action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:65:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:29:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
vendor/bundle/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
vendor/bundle/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:75:in `optimized_each'
vendor/bundle/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
vendor/bundle/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:532:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/etag.rb:23:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/conditionalget.rb:35:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/head.rb:14:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/flash.rb:243:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/session/abstract/id.rb:195:in `context'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/session/abstract/id.rb:190:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/cookies.rb:331:in `call'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/query_cache.rb:62:in `call'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:68:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/sendfile.rb:101:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/rack/logger.rb:13:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/methodoverride.rb:24:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/runtime.rb:17:in `call'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/lock.rb:15:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/static.rb:53:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/engine.rb:456:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/rack/content_length.rb:16:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:14:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.3.9/lib/rack/handler/webrick.rb:59:in `service'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

我无法弄清楚为什么我不断收到此错误。任何帮助将不胜感激。

4

1 回答 1

0

我遇到了同样的问题,并记得我最近更新了我的 aws-sdk、回形针、可卡因宝石。我最终做的是将回形针锁定到版本“3.0.4”,将 aws-sdk 锁定到最新版本“~> 1.8.3.1”,并将可卡因锁定在“0.3.2”。这解决了 imagemagick 和 amazon 的问题。我知道这并不能真正解决问题,但它对我有用。

于 2013-03-05T20:39:10.273 回答