mirror of
https://github.com/redmine/redmine.git
synced 2025-11-11 15:56:03 +01:00
File upload fails when run with uWSGI (#35715).
Contributed by Pavel Rosický and Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@21173 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -105,7 +105,7 @@ class AttachmentsController < ApplicationController
|
||||
return
|
||||
end
|
||||
|
||||
@attachment = Attachment.new(:file => request.body)
|
||||
@attachment = Attachment.new(:file => raw_request_body)
|
||||
@attachment.author = User.current
|
||||
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
|
||||
@attachment.content_type = params[:content_type].presence
|
||||
@@ -303,4 +303,14 @@ class AttachmentsController < ApplicationController
|
||||
def update_all_params
|
||||
params.permit(:attachments => [:filename, :description]).require(:attachments)
|
||||
end
|
||||
|
||||
# Get an IO-like object for the request body which is usable to create a new
|
||||
# attachment. We try to avoid having to read the whole body into memory.
|
||||
def raw_request_body
|
||||
if request.body.respond_to?(:size)
|
||||
request.body
|
||||
else
|
||||
request.raw_post
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user