title: Upload local file with fetch / content-type: octet-stream
body: <p>I am currently developing a Sketch Plugin, where an image gets sent to the Microsoft Custom Vision API for object detection.</p>
  
  <p>The Sketch Plugin itself is written in Javascript, a fs polyfill and a fetch polyfill is available. An API call with an image url works perfectly fine. However, I have trouble sending a local file from my computer as I am not 100% how I can access it. </p>
  
  <pre><code>    var templateUrl = require('../assets/test.png').replace('file://', '');
      var file = fs.readFileSync(templateUrl);
  
      var request = postData('https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction/XXXXXXX/image');
      request.then(data =&gt; data.json()).then(data =&gt; myFunction(data));
  
      // post request with file
      function postData(url, data) {
      return fetch(url, {  
          method: 'POST',  
          headers: {  
            'Prediction-Key': 'XXXXXXXXXX',
            'Content-Type': 'application/octet-stream',
          },  
          body: file,
      })
  }
  </code></pre>
  
  <p>Does anyone have experience with sending local files to the image recognition API? Any help would be very much appreciated!</p>
  
  <p>Thanks in advance!</p>
  
  <p>Best, C</p>