title: Fetch upload a picture as base64 instead of file
body: <p>I have created an endpoint to upload an avatar with my nodeJS API.</p>
  <p>The endpoint works fine when I use it from POSTMAN.</p>
  <p>But it doesn't work when I call it with Fetch from my react-js app.</p>
  <p>When I use Fetch to call the endpoint, the busboy.on('file', () = {...}) seems to be not triggered.</p>
  <p>The fetch method in my react-js app:</p>
  <pre><code>export const fetchPostFile = async (url, file) =&gt; {
  
    try {
  
      const data = new FormData();
      data.append(&quot;image&quot;, file);
      
      const rawResponse = await fetch(url, {
        method: 'POST',
        body: data
      });
  
      return await rawResponse.json();
  
    } catch (error) {
  
      console.error(error);
      return {success: false, message: 'query_can_not_be_sent'};
  
    }
  
  }
  </code></pre>
  <p>The input formData sent by reactjs:</p>
  <pre><code>------WebKitFormBoundary5WI3GuEx81A7nLq0
  Content-Disposition: form-data; name=&quot;image&quot;
  
  data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/7QL6UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAt0cAQAAAgACHAEUAAIAARwBFgACAAIcAR4ACUFGUC1QSE9UTxwBKAAIMTIzNDU2NzgcATwAATUcAUYACDIwMjAxMDExHAFQAAsxNTU5MjcrMDAwMBwBWgADGy1BHAFkAApBRlBfOFJWOUFQHAIAAAIAAhwCBQAZVEVOTklTLUZSQS1PUEVOLU1F...
  </code></pre>
  <p>The api method to upload the avatar</p>
  <pre><code>exports.postAvatar = async (request, response) =&gt; {
  
    response.set('Access-Control-Allow-Origin', '*');
    response.set('Access-Control-Allow-Headers', '*');
  
    const BusBoy = require('busboy');
    const fs = require('fs');
    const os = require('os');
    const path = require('path');
  
    const busboy = new BusBoy({ headers: request.headers });
    
    busboy.on('file', (fieldname, file, filename, encoding, mimetype) =&gt; {
      console.log('busboy.on(file)');
    });
  
    busboy.on('finish', async () =&gt; {
      console.log('busboy.on(finish)');
    });
  
    busboy.end(request.rawBody);
  
    return response.json({message: 'ok'});
  
  }
  </code></pre>
  <p><code>busboy.on(file)</code> message is not displayed when I call from reactjs but it is displayed with a postman call.</p>
  <p>EDIT:</p>
  <p>I checked the POSTMAN input and the image is not sent as base64 but like this:</p>
  <p><a href="https://i.stack.imgur.com/oa8En.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oa8En.png" alt="postman body" /></a></p>
  <p>In Postman, I tried with a base64 picture in a field text in input and I have the same result that with Fetch.</p>
  <p>Is busboy can receive a base64 encoded image ? Or can I convert the base64 picture to a file input ?</p>