2

我正在尝试使用回形针来处理上传到 S3 的图像文件。在我的用户模型中:

validates_attachment :avatar, :content_type => { :content_type => ["image/jpg", "image/png"] }, :size => { :in => 0..500.kilobytes }

上传图片时出现以下错误:

Command :: identify -format %wx%h "C:/Users/Tom/AppData/Local/Temp/rails121215-6332-1o1oxtk-30333.png[0]"
Completed 500 Internal Server Error in 277ms

NoMethodError (undefined method `exitstatus' for nil:NilClass)

此处的类似问题表明运行某些 imageMagick 命令时存在问题。但是,我已经设置Paperclip.options[:command_path]了,这没有什么区别。Imagemagick 也在路径上,如果我identify -format %wx%h "C:/Users/Tom/AppData/Local/Temp/rails121215-6332-1o1oxtk-30333.png[0]"在命令提示符下执行,我会50x64返回。此外,我正在使用扭矩箱,并且在扭矩箱窗口中出于某种原因打印了以下内容:14:59:11,205 INFO [stdout] (Thread-144) 50x64因此该命令显然是以某种方式执行的。

我也尝试过使用Cocaine::CommandLine.runner = Cocaine::CommandLine::BackticksRunner.new,但这只会导致以下错误: Errno::EINVAL (Invalid argument - =ExitCode)

如果有任何区别,我正在使用带有 Torquebox 的 JRuby。

这是跟踪:

cocaine (0.4.2) lib/cocaine/command_line.rb:80:in `run'
paperclip (3.3.1) lib/paperclip/helpers.rb:31:in `run'
paperclip (3.3.1) lib/paperclip/geometry.rb:23:in `from_file'
activesupport (3.2.8) lib/active_support/core_ext/kernel/reporting.rb:43:in `silence_stream'
paperclip (3.3.1) lib/paperclip/geometry.rb:22:in `from_file'
paperclip (3.3.1) lib/paperclip/thumbnail.rb:35:in `initialize'
paperclip (3.3.1) lib/paperclip/processor.rb:33:in `make'
paperclip (3.3.1) lib/paperclip/attachment.rb:410:in `post_process_style'
org/jruby/RubyArray.java:1615:in `each'
org/jruby/RubyEnumerable.java:830:in `inject'
paperclip (3.3.1) lib/paperclip/attachment.rb:409:in `post_process_style'
paperclip (3.3.1) lib/paperclip/attachment.rb:402:in `post_process_styles'
org/jruby/RubyHash.java:1186:in `each'
paperclip (3.3.1) lib/paperclip/attachment.rb:401:in `post_process_styles'
paperclip (3.3.1) lib/paperclip/attachment.rb:394:in `post_process'
activesupport (3.2.8) lib/active_support/callbacks.rb:406:in `_run__1796712306__avatar_post_process__1832820880__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_avatar_post_process_callbacks'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
paperclip (3.3.1) lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
paperclip (3.3.1) lib/paperclip/attachment.rb:393:in `post_process'
activesupport (3.2.8) lib/active_support/callbacks.rb:406:in `_run__1796712306__post_process__1832820880__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_post_process_callbacks'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
paperclip (3.3.1) lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
paperclip (3.3.1) lib/paperclip/attachment.rb:392:in `post_process'
paperclip (3.3.1) lib/paperclip/attachment.rb:107:in `assign'
paperclip (3.3.1) lib/paperclip.rb:196:in `avatar='
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activerecord (3.2.8) lib/active_record/attribute_assignment.rb:85:in `assign_attributes'
org/jruby/RubyHash.java:1186:in `each'
activerecord (3.2.8) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.8) lib/active_record/persistence.rb:215:in `update_attributes'
activerecord (3.2.8) lib/active_record/transactions.rb:295:in `with_transaction_returning_status'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
torquebox-transactions (2.1.2) lib/torquebox/active_record_adapters.rb:37:in `transaction'
activerecord (3.2.8) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.8) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.8) lib/active_record/persistence.rb:214:in `update_attributes'
app/controllers/users_controller.rb:11:in `update'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:418:in `_run__841617381__process_action__1679400720__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:225:in `_conditional_callback_around_260'
activesupport (3.2.8) lib/active_support/callbacks.rb:326:in `around'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:314:in `_callback_around_23'
activesupport (3.2.8) lib/active_support/callbacks.rb:224:in `_conditional_callback_around_260'
activesupport (3.2.8) lib/active_support/callbacks.rb:417:in `_run__841617381__process_action__1679400720__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_process_action_callbacks'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `action'
org/jruby/RubyProc.java:258:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `call'
org/jruby/RubyArray.java:1615:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
sass (3.1.20) lib/sass/plugin/rack.rb:54:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `call'
org/jruby/RubyKernel.java:1197:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
torquebox-web-2.1.2 (java) lib/torquebox/session/servlet_store.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
activesupport (3.2.8) lib/active_support/callbacks.rb:408:in `_run__2062687110__call__1832820880__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_call_callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'
4

1 回答 1

0

我认为JRUBY不能产生它必须采取的进程。

按照您的描述尝试此Cocaine::CommandLine.runner = Cocaine::CommandLine::BackticksRunner.new操作,并结合将可卡因降级到 0.3.2

(在 JRuby 1.7.1 + Webrick 和 Ruby on Rails 上测试)

于 2012-12-24T10:44:46.467 回答