title: Using a Stream with Sharp in Node.js
body: <p>I have a Node.js app. In this app, I'm loading an image file from Azure Storage using <a href="https://azure.github.io/azure-storage-node/FileService.html" rel="nofollow noreferrer">this API</a>. Specifically, I'm using the <code>createReadStream</code> function. That function provides a stream to read from the image. Right now, my code looks like this:</p>
  
  <pre><code>let chunks = [];
  let sharp = require('sharp');
  
  let fileStream = this.fileService.createReadStream('[MY_SHARE]', '[MY_DIRECTORY]', '[MY_PICTURE_NAME]', (err, fileResult, res) =&gt; {
    console.log('Sharpening image...');
    console.log(imageChunks);
  
    sharp(chunks).resize(100, 100).toFile('resized.png', function(err1, info) {
      if (err1) {
        console.log('oops');
      }
    });
  });
  
  fileStream.on('data', function(chunk) {
    chunks.push(chunk);
  });
  </code></pre>
  
  <p>In this block, notice that I'm trying to use the <a href="https://github.com/lovell/sharp" rel="nofollow noreferrer">Sharp node module</a>. Before the line <code>sharp(chunks)...</code>, I'm printing out image chunks to the console. When printed in the console, I see the following:</p>
  
  <pre><code>[ &lt;Buffer 87 52 4e 47 0d 0a 1a 0a 01 02 04 0d 49 48 44 52 00 00 06 18 00 00 06 0f 08 06 00 00 00 75 c2 f0 a2 00 00 00 04 67 42 4d 41 00 00 b2 8f 0a fc 61 05 00 ... &gt; ]
  </code></pre>
  
  <p>However, when I call Sharp, I get an error that says:</p>
  
  <pre><code>Error: Unsupported input object
  </code></pre>
  
  <p>According to the docs, the <a href="http://sharp.dimens.io/en/stable/api-constructor/" rel="nofollow noreferrer">Sharp Constructor</a> allows for either a String or a Buffer. Looking at what's printed to the console as shown above, it looks like I'm passing a Buffer to Sharp. Am I misunderstanding something? If so, what?</p>