Macrow / rails_kindeditor

Kindeditor for Ruby on Rails
260 stars 108 forks source link

多图片上传显示失败,单个图片上传成功 #49

Closed sunbo closed 11 years ago

sunbo commented 11 years ago

这个是上传多个图片时的log,失败

Started POST "/kindeditor/upload?dir=image" for 127.0.0.1 at 2013-08-19 21:23:30 +0800
Processing by Kindeditor::AssetsController#create as HTML
  Parameters: {"Filename"=>"2c7c2d0ae5b27e5db628f71449b1f951.jpg", "imgFile"=>#<ActionDispatch::Http::UploadedFile:0x007fc2025b6bb8 @tempfile=#<Tempfile:/var/folders/nj/bbd26pcd72bdtpd6n4dkd5b00000gn/T/RackMultipart20130819-11357-553tli>, @original_filename="2c7c2d0ae5b27e5db628f71449b1f951.jpg", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"imgFile\"; filename=\"2c7c2d0ae5b27e5db628f71449b1f951.jpg\"\r\nContent-Type: application/octet-stream\r\n">, "Upload"=>"Submit Query", "dir"=>"image"}
Completed 401 Unauthorized in 1ms

这个是上传1个图片时的log,成功

Started POST "/kindeditor/upload?dir=image" for 127.0.0.1 at 2013-08-19 21:24:46 +0800
Processing by Kindeditor::AssetsController#create as HTML
  Parameters: {"localUrl"=>"C:\\fakepath\\1 copy.jpg", "imgFile"=>#<ActionDispatch::Http::UploadedFile:0x007fc2060bb330 @tempfile=#<Tempfile:/var/folders/nj/bbd26pcd72bdtpd6n4dkd5b00000gn/T/RackMultipart20130819-11357-9f9sb8>, @original_filename="1 copy.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"imgFile\"; filename=\"1 copy.jpg\"\r\nContent-Type: image/jpeg\r\n">, "dir"=>"image"}
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
  Rendered text template (0.0ms)
Completed 200 OK in 10ms (Views: 0.5ms | ActiveRecord: 0.5ms)
Macrow commented 11 years ago

我这里测试,多图片上传是正常可用的,没有错误。

多图片上传实际上只是多次调用单图片上传的代码,没什么区别。

从你的log看,是401 Unauthorized错误,你看看是不是哪里权限配置有问题。

sunbo commented 11 years ago

多个图片上传也是传到public/uploads下吧,一个图片上传是可以,应该没有权限问题,我是本地测试的。 多个图片上传 content_type="application/octet-stream" 一个图片上传 content_type="image/jpeg" 会不会是这个问题?

Macrow commented 11 years ago

我上传两张图片的log是这样的,没有问题。

Started POST "/kindeditor/upload?dir=image" for 127.0.0.1 at 2013-08-21 23:03:04 +0800
Processing by Kindeditor::AssetsController#create as HTML
  Parameters: {"Filename"=>"2013060204.jpg", "imgFile"=>#<ActionDispatch::Http::UploadedFile:0x007ff79b386608 @tempfile=#<Tempfile:/var/folders/z0/j5pmgzyd5lvdx1tmg5xvvp800000gn/T/RackMultipart20130821-592-kfq8rs>, @original_filename="2013060204.jpg", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"imgFile\"; filename=\"2013060204.jpg\"\r\nContent-Type: application/octet-stream\r\n">, "Upload"=>"Submit Query", "dir"=>"image"}
   (0.1ms)  begin transaction
Binary data inserted for `string` type on column `file_type`
  SQL (0.5ms)  INSERT INTO "kindeditor_assets" ("asset", "asset_type", "created_at", "file_size", "file_type", "owner_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["asset", "d473038c5354.jpg"], ["asset_type", "image"], ["created_at", Wed, 21 Aug 2013 15:03:04 UTC +00:00], ["file_size", 21816], ["file_type", "application/octet-stream"], ["owner_id", 0], ["updated_at", Wed, 21 Aug 2013 15:03:04 UTC +00:00]]
   (0.8ms)  commit transaction
  Rendered text template (0.0ms)
Completed 200 OK in 58ms (Views: 0.5ms | ActiveRecord: 1.7ms)

Started POST "/kindeditor/upload?dir=image" for 127.0.0.1 at 2013-08-21 23:03:04 +0800
Processing by Kindeditor::AssetsController#create as HTML
  Parameters: {"Filename"=>"2013060205.jpg", "imgFile"=>#<ActionDispatch::Http::UploadedFile:0x007ff79f8bcd80 @tempfile=#<Tempfile:/var/folders/z0/j5pmgzyd5lvdx1tmg5xvvp800000gn/T/RackMultipart20130821-592-vs9hlt>, @original_filename="2013060205.jpg", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"imgFile\"; filename=\"2013060205.jpg\"\r\nContent-Type: application/octet-stream\r\n">, "Upload"=>"Submit Query", "dir"=>"image"}
   (0.1ms)  begin transaction
Binary data inserted for `string` type on column `file_type`
  SQL (0.5ms)  INSERT INTO "kindeditor_assets" ("asset", "asset_type", "created_at", "file_size", "file_type", "owner_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?)  [["asset", "33e2a80b3dd1.jpg"], ["asset_type", "image"], ["created_at", Wed, 21 Aug 2013 15:03:04 UTC +00:00], ["file_size", 23871], ["file_type", "application/octet-stream"], ["owner_id", 0], ["updated_at", Wed, 21 Aug 2013 15:03:04 UTC +00:00]]
   (0.6ms)  commit transaction
  Rendered text template (0.0ms)
Completed 200 OK in 10ms (Views: 0.4ms | ActiveRecord: 1.2ms)
Macrow commented 11 years ago

目前没有更多反馈,此问题暂时关闭。

FlowerWrong commented 10 years ago

我野发现了这个问题,但是应该市kindeditor的问题,多图上传的时候如果带权限管理那么就会出错. 例如,我要求使用编辑器必须登陆,require_login,那么酒无法取得current_user值,我猜测是cookie问题.