How to correctly format a POST request to the file_upload Rest Response?
Recently I have faced the same issue in a file upload. For this, I have done base64_decode() before the file_save_data() in Drupal.
Example code:

  if (isset($file_data['title']) &amp;&amp; isset($file_data['data'])) {
      // Get base64_encode of file data and explode to get data.
      $encodedImgString = explode(',', $file_data['data'], 2)[1];
      // Decode the data.
      $decodedImgString = base64_decode($encodedImgString);
      // Get the file name.
      $file_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file_data['title']);*/
      // Save the file using base_decode() data.
      $file = file_save_data($decodedImgString, 'public://' . $file_data['title'], FILE_EXISTS_RENAME);
      $file_result = [
        'target_id' =&gt; $file-&gt;id(),
        'title' =&gt; $file_data['title'],
      ];
    }


Hope this helps you.

Note: Here I have used custom REST API for file uploads.