Node.js: How to read a stream into a buffer?

前端 未结 6 1802
野趣味
野趣味 2020-12-07 12:05

I wrote a pretty simple function that downloads an image from a given URL, resize it and upload to S3 (using \'gm\' and \'knox\'), I have no idea if I\'m doing the reading o

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 12:38

    You can easily do this using node-fetch if you are pulling from http(s) URIs.

    From the readme:

    fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
        .then(res => res.buffer())
        .then(buffer => console.log)
    

提交回复
热议问题