Rails Active Storage ActiveStorage :: IntegrityError(ActiveStorage :: IntegrityError):尝试上传时

时间:2018-08-28 04:39:00

标签: ruby-on-rails

我希望您能对我有所帮助,我一直在遵循以下指南:https://edgeguides.rubyonrails.org/active_storage_overview.html,以使用Azure来实现活动存储,但是在上传文件时遇到了问题。

它总是抛出此错误:ActiveStorage :: IntegrityError(ActiveStorage :: IntegrityError)

日志显示以下内容:

Processing by SliderController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"nx5HaniUlhwMBjtJPXW9safsafw6oT7PDog4aDg0XPC8Yasfas+T57ZYP0NJ7xWMI6halogBy0VO3Sg==", "slider"=>{"key"=>"home", "image"=>#<ActionDispatch::Http::UploadedFile:0xd5151f8 @tempfile=#<Tempfile:C:/Users/user/AppData/Local/Temp/RackMultipart20180827-34920-1ulxtdy.jpg>, @original_filename="30714520_1071308403021677_2686322307856596992_n.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"slider[image]\"; filename=\"30714520_1071308403021677_2686322307856596992_n.jpg\"\r\nContent-Type: image/jpeg\r\n">, "content"=>"asxa", "text2"=>"asxs", "link"=>"", "button"=>"More..."}, "commit"=>"Crete Slider"}
          AzureStorage Storage (559.5ms) Uploaded file to key: yx4Qm4HA4wD9Ux7P3VhPqEFv (checksum: LO4ccLCw2J1w5TKgyxGG1g==)
        Completed 500 Internal Server Error in 573ms (ActiveRecord: 0.0ms)

        ActiveStorage::IntegrityError (ActiveStorage::IntegrityError)
    activestorage (5.2.1) lib/active_storage/service/azure_storage_service.rb:25:in `rescue in block in upload'
    activestorage (5.2.1) lib/active_storage/service/azure_storage_service.rb:22:in `block in upload'
    activesupport (5.2.1) lib/active_support/notifications.rb:168:in `block in instrument'
    activesupport (5.2.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    activesupport (5.2.1) lib/active_support/notifications.rb:168:in `instrument'
    activestorage (5.2.1) lib/active_storage/service.rb:118:in `instrument'
    activestorage (5.2.1) lib/active_storage/service/azure_storage_service.rb:21:in `upload'
    activestorage (5.2.1) app/models/active_storage/blob.rb:155:in `upload'
    activestorage (5.2.1) app/models/active_storage/blob.rb:53:in `block in build_after_upload'
    activestorage (5.2.1) app/models/active_storage/blob.rb:48:in `tap'
    activestorage (5.2.1) app/models/active_storage/blob.rb:48:in `build_after_upload'
    activestorage (5.2.1) app/models/active_storage/blob.rb:61:in `create_after_upload!'
    activestorage (5.2.1) lib/active_storage/attached.rb:23:in `create_blob_from'
    activestorage (5.2.1) lib/active_storage/attached/one.rb:24:in `attach'
    activestorage (5.2.1) lib/active_storage/attached/macros.rb:37:in `imagen='
    activemodel (5.2.1) lib/active_model/attribute_assignment.rb:51:in `public_send'
    activemodel (5.2.1) lib/active_model/attribute_assignment.rb:51:in `_assign_attribute'
    activemodel (5.2.1) lib/active_model/attribute_assignment.rb:44:in `block in _assign_attributes'
    activemodel (5.2.1) lib/active_model/attribute_assignment.rb:43:in `each'
    activemodel (5.2.1) lib/active_model/attribute_assignment.rb:43:in `_assign_attributes'
    activerecord (5.2.1) lib/active_record/attribute_assignment.rb:23:in `_assign_attributes'
    activemodel (5.2.1) lib/active_model/attribute_assignment.rb:35:in `assign_attributes'
    activerecord (5.2.1) lib/active_record/core.rb:314:in `initialize'
    activerecord (5.2.1) lib/active_record/inheritance.rb:66:in `new'
    activerecord (5.2.1) lib/active_record/inheritance.rb:66:in `new'
    cancancan (2.2.0) lib/cancan/controller_resource_builder.rb:6:in `build_resource'
    cancancan (2.2.0) lib/cancan/controller_resource_loader.rb:104:in `load_resource_instance'
    cancancan (2.2.0) lib/cancan/controller_resource_loader.rb:15:in `load_resource'
    cancancan (2.2.0) lib/cancan/controller_resource.rb:31:in `load_and_authorize_resource'
    cancancan (2.2.0) lib/cancan/controller_resource.rb:15:in `block in add_before_action'
    activesupport (5.2.1) lib/active_support/callbacks.rb:426:in `instance_exec'
    activesupport (5.2.1) lib/active_support/callbacks.rb:426:in `block in make_lambda'
    activesupport (5.2.1) lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    actionpack (5.2.1) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
    activesupport (5.2.1) lib/active_support/callbacks.rb:199:in `block in halting'
    activesupport (5.2.1) lib/active_support/callbacks.rb:513:in `block in invoke_before'
    activesupport (5.2.1) lib/active_support/callbacks.rb:513:in `each'
    activesupport (5.2.1) lib/active_support/callbacks.rb:513:in `invoke_before'
    activesupport (5.2.1) lib/active_support/callbacks.rb:131:in `run_callbacks'
    actionpack (5.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
    actionpack (5.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
    actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
    activesupport (5.2.1) lib/active_support/notifications.rb:168:in `block in instrument'
    activesupport (5.2.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    activesupport (5.2.1) lib/active_support/notifications.rb:168:in `instrument'
    actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
    actionpack (5.2.1) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
    activerecord (5.2.1) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
    actionpack (5.2.1) lib/abstract_controller/base.rb:134:in `process'
    actionview (5.2.1) lib/action_view/rendering.rb:32:in `process'
    actionpack (5.2.1) lib/action_controller/metal.rb:191:in `dispatch'
    actionpack (5.2.1) lib/action_controller/metal.rb:252:in `dispatch'
    actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
    actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:34:in `serve'
    actionpack (5.2.1) lib/action_dispatch/journey/router.rb:52:in `block in serve'
    actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `each'
    actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `serve'
    actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:840:in `call'
    rack (2.0.5) lib/rack/tempfile_reaper.rb:15:in `call'
    rack (2.0.5) lib/rack/etag.rb:25:in `call'
    rack (2.0.5) lib/rack/conditional_get.rb:38:in `call'
    rack (2.0.5) lib/rack/head.rb:12:in `call'
    actionpack (5.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
    rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
    rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/cookies.rb:670:in `call'
    activerecord (5.2.1) lib/active_record/migration.rb:559:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
    activesupport (5.2.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
    actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
    web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
    web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
    web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
    railties (5.2.1) lib/rails/rack/logger.rb:38:in `call_app'
    railties (5.2.1) lib/rails/rack/logger.rb:26:in `block in call'
    activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `block in tagged'
    activesupport (5.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
    activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `tagged'
    railties (5.2.1) lib/rails/rack/logger.rb:26:in `call'
    sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
    request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
    rack (2.0.5) lib/rack/method_override.rb:22:in `call'
    rack (2.0.5) lib/rack/runtime.rb:22:in `call'
    activesupport (5.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
    actionpack (5.2.1) lib/action_dispatch/middleware/static.rb:127:in `call'
    rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
    railties (5.2.1) lib/rails/engine.rb:524:in `call'
    rack (2.0.5) lib/rack/handler/webrick.rb:86:in `service'
    C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
    C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
    C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

我一步一步地遵循了指南,但仍然存在相同的错误,任何人都可以帮助我并向我解释我所缺少的内容吗?谢谢

0 个答案:

没有答案