Download xlsx from S3 and parse it
<p>I need a service to download an excel file from Amazon S3, then parse with <a href="https://www.npmjs.com/package/node-xlsx" rel="noreferrer">node-xlsx</a></p>

<p>The problem is that I can't get xlsx to parse the file. When I try to read back the file I just wrote, it isn't found by the code.</p>

<p>I'm not quite sure if this is the best approach, but this is what I got so far:</p>

<pre><code>router.get('/process', (req, res) =&gt; {
    var fileName = 'https://some-bucket.s3.amazonaws.com/some-excel-file.xlsx'
    https.get(fileName, response =&gt; {
        var body = ''
        response.on('data', chunk =&gt; body += chunk)
        response.on('end', () =&gt; {

            //fs is being imported early on this file
            fs.writeFile(__dirname + '/test.xlsx', body)

            var f = fs.createReadStream(__dirname + '/test.xlsx')

            var book = xlsx.parse(f)
            book.forEach(sheet =&gt; console.log('sheet', sheet.name) )

            res.status(200)          
        })
        .on('error', e =&gt; {
            res.status(500)
        })
    })
    return
})
</code></pre>