how to load an image from url into buffer in nodejs

前端 未结 5 972
谎友^
谎友^ 2020-12-29 19:31

I am new to nodejs and am trying to set up a server where i get the exif information from an image. My images are on S3 so I want to be able to just pass in the s3 url as a

5条回答
  •  太阳男子
    2020-12-29 20:20

    Try setting up request like this:

    var request = require('request').defaults({ encoding: null });
    request.get(s3Url, function (err, res, body) {
          //process exif here
    });
    

    Setting encoding to null will cause request to output a buffer instead of a string.

提交回复
热议问题