title: Generate body for multipart file upload using fetch in Javascript
body: <p>I am trying to upload a file(uploadType=multipart) to Drive API V3 using fetch but the body is wrong as it is creating a file with the title unnamed.</p>
  <pre><code>var  tmpFile=document.getElementById('inputFile').files;
   tmpFile=tmpFile[0];
  
  await  fetch('https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart', {
      method: 'POST', // or 'PUT'
      headers: {
          'Authorization': 'Bearer '+accessToken,
  
        },
      body: {
              metadata:{
                         'name':tmpFile.name,
                         'Content-Type':'application/json; charset=UTF-8' 
              },
              media:{
                  'Content-Type': '*/*',
                  'name':tmpFile
              }
      }
  
      })
      .then(response =&gt; response.json())
      .then(data =&gt; {
      console.log('Success:', data);
      })
      .catch((error) =&gt; {
      console.error('Error:', error);
  });
  </code></pre>