我尝试过以下代码,但是收到错误:Error: EACCES, open 'out'
var out = fs.createWriteStream('out');
request(url).pipe(zlib.createGunzip()).pipe(out);
var s3obj = new aws.S3({ params: { Bucket: 'mybucket', Key: 'mykey' } });
s3obj.upload({ Body: out }, function(err, data) {
context.succeed("Completed");
});
答案 0 :(得分:0)
node.js是异步的,所以你必须这样做:
var s3obj = new aws.S3({ params: { Bucket: 'mybucket', Key: 'mykey' } });
var out = fs.createWriteStream('out');
request(url).pipe(zlib.createGunzip()).pipe(out)
.on('end', function() {
var uploadStream = fs.createReadStream('out')
s3obj.upload({ Body: uploadStream }, function(err, data) {
context.succeed("Completed");
});