Project

General

Profile

Defect #35715 » 35715.patch

Patch by Pavel Rosický and Holger Just - Go MAEDA, 2021-08-12 06:40

View differences:

app/controllers/attachments_controller.rb
105 105
      return
106 106
    end
107 107

  
108
    @attachment = Attachment.new(:file => request.body)
108
    @attachment = Attachment.new(:file => raw_request_body)
109 109
    @attachment.author = User.current
110 110
    @attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
111 111
    @attachment.content_type = params[:content_type].presence
......
303 303
  def update_all_params
304 304
    params.permit(:attachments => [:filename, :description]).require(:attachments)
305 305
  end
306

  
307
  # Get an IO-like object for the request body which is usable to create a new
308
  # attachment. We try to avoid having to read the whole body into memory.
309
  def raw_request_body
310
    if request.body.respond_to?(:size)
311
      request.body
312
    else
313
      request.raw_body
314
    end
315
  end
306 316
end
(1-1/2)