title: Write a ReadableStream image to file
body: <p>I've been trying different things all day, but nothing seems to offer a simple, straight-forward way to write a <code>ReadableStream</code> (which is an image) to a file. I'm calling an API which returns a <code>ReadableStream</code>, but what then? I tried digging into the object a bit more, and followed it all the way to returning a <code>Buffer[]</code>, which seems like it should be what needs to go into a <code>fs.writeFile()</code> but nothing works. The file gets created but I try to open the image and it says it can't open that file type (which file type they're talking about, I have no idea).</p>
  
  <p>Here is my code that returns a <code>Buffer[]</code>. I can also cut off some of those chains to only return the <code>ReadableStream</code> body, but then that returns a <code>PullThrough</code> and I am already so lost. Very little about that class online. Any suggestions?</p>
  
  <p>Here is the api I'm using: <a href="https://docs.microsoft.com/en-us/javascript/api/@azure/cognitiveservices-computervision/computervisionclient?view=azure-node-latest#generatethumbnail-number--number--string--computervisionclientgeneratethumbnailoptionalparams--servicecallback-void--" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/javascript/api/@azure/cognitiveservices-computervision/computervisionclient?view=azure-node-latest#generatethumbnail-number--number--string--computervisionclientgeneratethumbnailoptionalparams--servicecallback-void--</a> </p>
  
  <pre><code>  // Image of a dog.
    const dogURL = 'https://moderatorsampleimages.blob.core.windows.net/samples/sample16.png';
    await computerVisionClient.generateThumbnail(100, 100, dogURL, { smartCropping: true } )
        .then((thumbResponse) =&gt; {
          console.log(thumbResponse.readableStreamBody.readableBuffer.head.data)
          fs.writeFile("thumb.jpg", thumbResponse.readableStreamBody.readableBuffer.head.data, "binary", (err) =&gt; {
            console.log('Thumbnail saved')
            if (err) throw err
          })
        })
  </code></pre>