Fixed that REST Uploads fail with fastcgi in 1.4-stable (#10832).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9653 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fa4fdf91a4
commit
eb53d600c9
|
@ -67,7 +67,7 @@ class AttachmentsController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@attachment = Attachment.new(:file => request.body)
|
@attachment = Attachment.new(:file => request.raw_post)
|
||||||
@attachment.author = User.current
|
@attachment.author = User.current
|
||||||
@attachment.filename = Redmine::Utils.random_hex(16)
|
@attachment.filename = Redmine::Utils.random_hex(16)
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,15 @@ class Attachment < ActiveRecord::Base
|
||||||
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
||||||
md5 = Digest::MD5.new
|
md5 = Digest::MD5.new
|
||||||
File.open(diskfile, "wb") do |f|
|
File.open(diskfile, "wb") do |f|
|
||||||
buffer = ""
|
if @temp_file.respond_to?(:read)
|
||||||
while (buffer = @temp_file.read(8192))
|
buffer = ""
|
||||||
f.write(buffer)
|
while (buffer = @temp_file.read(8192))
|
||||||
md5.update(buffer)
|
f.write(buffer)
|
||||||
|
md5.update(buffer)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
f.write(@temp_file)
|
||||||
|
md5.update(@temp_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.digest = md5.hexdigest
|
self.digest = md5.hexdigest
|
||||||
|
|
Loading…
Reference in New Issue