jeffreyguenther / activestorage-openstack

An OpenStack service for Active Storage
MIT License
4 stars 0 forks source link

Direct upload checksum error #2

Open gregoirenovel opened 6 years ago

gregoirenovel commented 6 years ago

Running Rails 5.2.0.beta2, I encounter an error while trying to direct upload an attachement through ActiveStorage and activestorage-openstack.

In the browser, I get the following error in an alert: Error creating Blob for "metro_mini_plan_v2017-01.pdf". Status: 500

Stacktrace (click to expand) ``` Started POST "/rails/active_storage/direct_uploads" for 127.0.0.1 at 2017-11-28 14:22:49 +0100 Processing by ActiveStorage::DirectUploadsController#create as JSON Parameters: {"blob"=>{"filename"=>"metro_mini_plan_v2017-01.pdf", "content_type"=>"application/pdf", "byte_size"=>828549, "checksum"=>"yckW+Mex8voiP0RDicL7+w=="}, "direct_upload"=>{"blob"=>{"filename"=>"metro_mini_plan_v2017-01.pdf", "content_type"=>"application/pdf", "byte_size"=>828549, "checksum"=>"yckW+Mex8voiP0RDicL7+w=="}}} (0.1ms) begin transaction ActiveStorage::Blob Create (2.8ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "byte_size", "checksum", "created_at") VALUES (?, ?, ?, ?, ?, ?) [["key", "hmVym4XqVde41v8EtosG94iz"], ["filename", "metro_mini_plan_v2017-01.pdf"], ["content_type", "application/pdf"], ["byte_size", 828549], ["checksum", "yckW+Mex8voiP0RDicL7+w=="], ["created_at", "2017-11-28 13:22:49.446671"]] (1.8ms) commit transaction Completed 500 Internal Server Error in 15ms (ActiveRecord: 5.0ms) ArgumentError (unknown keyword: checksum): /Users/gnovel/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/bundler/gems/activestorage-openstack-09553a67161b/lib/active_storage/service/open_stack_service.rb:71:in `url_for_direct_upload' activestorage (5.2.0.beta2) app/models/active_storage/blob.rb:197:in `service_url_for_direct_upload' activestorage (5.2.0.beta2) app/controllers/active_storage/direct_uploads_controller.rb:19:in `direct_upload_json' activestorage (5.2.0.beta2) app/controllers/active_storage/direct_uploads_controller.rb:9:in `create' actionpack (5.2.0.beta2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action' actionpack (5.2.0.beta2) lib/abstract_controller/base.rb:194:in `process_action' actionpack (5.2.0.beta2) lib/action_controller/metal/rendering.rb:30:in `process_action' actionpack (5.2.0.beta2) lib/abstract_controller/callbacks.rb:42:in `block in process_action' activesupport (5.2.0.beta2) lib/active_support/callbacks.rb:132:in `run_callbacks' actionpack (5.2.0.beta2) lib/abstract_controller/callbacks.rb:41:in `process_action' actionpack (5.2.0.beta2) lib/action_controller/metal/rescue.rb:22:in `process_action' actionpack (5.2.0.beta2) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action' activesupport (5.2.0.beta2) lib/active_support/notifications.rb:168:in `block in instrument' activesupport (5.2.0.beta2) lib/active_support/notifications/instrumenter.rb:23:in `instrument' activesupport (5.2.0.beta2) lib/active_support/notifications.rb:168:in `instrument' actionpack (5.2.0.beta2) lib/action_controller/metal/instrumentation.rb:32:in `process_action' actionpack (5.2.0.beta2) lib/action_controller/metal/params_wrapper.rb:256:in `process_action' activerecord (5.2.0.beta2) lib/active_record/railties/controller_runtime.rb:24:in `process_action' actionpack (5.2.0.beta2) lib/abstract_controller/base.rb:134:in `process' actionview (5.2.0.beta2) lib/action_view/rendering.rb:32:in `process' actionpack (5.2.0.beta2) lib/action_controller/metal.rb:191:in `dispatch' actionpack (5.2.0.beta2) lib/action_controller/metal.rb:254:in `dispatch' actionpack (5.2.0.beta2) lib/action_dispatch/routing/route_set.rb:52:in `dispatch' actionpack (5.2.0.beta2) lib/action_dispatch/routing/route_set.rb:34:in `serve' actionpack (5.2.0.beta2) lib/action_dispatch/journey/router.rb:52:in `block in serve' actionpack (5.2.0.beta2) lib/action_dispatch/journey/router.rb:35:in `each' actionpack (5.2.0.beta2) lib/action_dispatch/journey/router.rb:35:in `serve' actionpack (5.2.0.beta2) lib/action_dispatch/routing/route_set.rb:830:in `call' rack (2.0.3) lib/rack/etag.rb:25:in `call' rack (2.0.3) lib/rack/conditional_get.rb:38:in `call' rack (2.0.3) lib/rack/head.rb:12:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/http/content_security_policy.rb:16:in `call' rack (2.0.3) lib/rack/session/abstract/id.rb:232:in `context' rack (2.0.3) lib/rack/session/abstract/id.rb:226:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/cookies.rb:663:in `call' activerecord (5.2.0.beta2) lib/active_record/migration.rb:558:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' activesupport (5.2.0.beta2) lib/active_support/callbacks.rb:98:in `run_callbacks' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/callbacks.rb:26:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call' web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app' web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call' web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch' web-console (3.5.1) lib/web_console/middleware.rb:18:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (5.2.0.beta2) lib/rails/rack/logger.rb:38:in `call_app' railties (5.2.0.beta2) lib/rails/rack/logger.rb:26:in `block in call' activesupport (5.2.0.beta2) lib/active_support/tagged_logging.rb:71:in `block in tagged' activesupport (5.2.0.beta2) lib/active_support/tagged_logging.rb:28:in `tagged' activesupport (5.2.0.beta2) lib/active_support/tagged_logging.rb:71:in `tagged' railties (5.2.0.beta2) 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.0.beta2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/request_id.rb:27:in `call' rack (2.0.3) lib/rack/method_override.rb:22:in `call' rack (2.0.3) lib/rack/runtime.rb:22:in `call' activesupport (5.2.0.beta2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (5.2.0.beta2) lib/action_dispatch/middleware/static.rb:127:in `call' rack (2.0.3) lib/rack/sendfile.rb:111:in `call' railties (5.2.0.beta2) lib/rails/engine.rb:524:in `call' puma (3.11.0) lib/puma/configuration.rb:225:in `call' puma (3.11.0) lib/puma/server.rb:624:in `handle_request' puma (3.11.0) lib/puma/server.rb:438:in `process_client' puma (3.11.0) lib/puma/server.rb:302:in `block in run' puma (3.11.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread' ```

I think everything is configured properly because:

jeffreyguenther commented 6 years ago

Yes, I'm not surprised that you've bumped into this because I've only naïvely implemented the direct upload based on the other services and not yet tested it. It's been on my todo list.

Let me look into this and get back to you. I'm in need of direct uploads myself.

jeffreyguenther commented 6 years ago

I've pushed code that will not cause this error anymore. However, a new error is present. I'm getting a CORS error when trying to post to the direct upload URL. Swift doesn't seem to be sending back the correct response during the OPTIONS request.

jeffreyguenther commented 6 years ago

Would you be willing to try using the current code in your OpenStack environment to see if you get the CORS errors? I'm trying to figure if the issue is with this code or the environment I'm working with.

jeffreyguenther commented 6 years ago

I've received word that the OpenStack provider I use doesn't support CORS so I'm not able to test the direct upload yet. I need to find a different provider.

gregoirenovel commented 6 years ago

I confirm that the checksum error is gone, however I now get a 401 from my open stack provider(but no sign of a CORS-related error for now), I'll investigate further and get back to you.