title: javascript send local file to api
body: <p>I'm developing an electron app which must call an api to replace (update) file X in server by file Y which is in my computer.
  The user download file X from Server in order to edit it, (this file will be named file Y in my computer).
  When the user finish to edit file Y, i check if both files X and Y are differents and i call the api in order to replace file X by file Y. I don't need to put file Y in a form before calling api, i want to do it without form.
  Only my request payload is different from what i expect to have, there is no problem in my request headers</p>
  
  <p>I expect to have something like that <a href="https://i.stack.imgur.com/o7abi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o7abi.png" alt="what i expect"></a>
  and i get this
  <a href="https://i.stack.imgur.com/hPjjl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hPjjl.png" alt="what i get"></a></p>
  
  <p>Here is what i do</p>
  
  <pre><code> const fs = require('fs');
    let fileY = fs.readFileSync(path.resolve('gitignore.txt'));
    let form = new FormData();
    form.append("type", "jur_document");
    form.append("file", fileY, 'gitignore.txt');
    form.append("saveActionType", "SAVEMAJOR");
    form.append("attributes", "MIMETYPE=text/plain");
  
    let settings = {
      "async": true,
      "url": `${Constante.URL}/documents`,
      "method": "POST",
      "type": "POST",
      "headers": {
        // "Content-Type": "text/plain",
        "Authorization": sessionStorage.getItem('authorization')
      },
      "processData": false,
      "contentType": false,
      "mimeType": "multipart/form-data",
      "data": form
    };
  
    $.ajax(settings)
      .done((response) =&gt; {
        console.log(response);
      }).fail(err =&gt; {
        console.log(err);
      });
  }
  </code></pre>