Problem: Attachments uploaded via RESTAPI still contain multipart content type header

I want to upload attachments to dedicated documents by the RESTAPI.
The following code tests the concept

{{html clean="false"}}
<script type="text/javascript">
var upload = null;
function uploadFile() {
  var file = document.getElementById("theForm").files[0];
  if(!file) return;
  var formData = new FormData();
  upload = new XMLHttpRequest();
  formData.append("anyName", file);"PUT",
<form action="" method="post" enctype="multipart/form-data">
  <input id="theForm" type="file" accept="*.*" onchange="uploadFile();"/>
  <input value="Upload" type="button" onclick="uploadFile();" />

It uploads the selected file to the target position using the source file name as the attachment name.


The attachment still contains multipart content header (known from email)


Source file “testdata.txt”:

line 01 - abcdef
line 02 - ghijkl
line 03 - mnopqr

gives attachment content:

Content-Disposition: form-data; name="anyName"; filename="testdata.txt"
Content-Type: text/plain

line 01 - abcdef
line 02 - ghijkl
line 03 - mnopqr

If the source is binary, e.g. an image, it results in

Content-Disposition: form-data; name="datei"; filename="Kugeln.jpg"
Content-Type: image/jpeg

<binary information>

How can the additional boundary information be suppressed?

XWiki version 13.10.3 is used
The target URI contains an additional “/xwiki” in the beginning due proxy use.