get a stream's content-length

后端 未结 2 1201
误落风尘
误落风尘 2021-01-04 03:17

In my node.js app, I\'m using gm (a graphicsmagick wrapper) and aws2js (amazon cli wrapper). The problem is that Amazon needs to know the content-length so that I can put th

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-04 04:04

    gm( fileStream ).filesize({bufferStream: true}, function (error, filesize) {
      this.stream(function (error, stdout, stderr) {
        aws.S3.putStream(path, stdout, 'public-read', {'content-length': filesize, 'content-type': 'image/png'}, function (error, result) {
          // .....       
        });
      });
    });
    

提交回复
热议问题