0

我真的很难上传到 S3。我想使用 STREAMING 将视频文件上传到 S3(即不在服务器上保存临时文件然后上传到 s3)

我不知道如何设置 s3 上传功能以使其从流中读取。似乎 connect-busboy 创建了一个没有人阅读的流。

这是我的代码:

app.post('/upload', function (req, res) {
console.log(req.body.FileBox);
req.busboy.on('file', function (fieldname, file, filename) {

     //videoUpload.upload(req.body.FileBox);
     var params = {
         Bucket: 'videogamblerside',
         Key: "chek",
         Body: file,
         ContentType: "video/mp4"
     };
    console.log(file);
    //file.resume();
    //  file.resume();
    s3.upload(params, function (err, data) {
        if (err) throw err;
    });
4

1 回答 1

0

可能你想添加ContentLength

此代码示例适用于我:

busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {



        s3Client.putObject({
          Bucket: bucket,
          Key: filename,
          ACL: 'public-read',
          Body: file,
          ContentLength: 3000,
        }, function(err, data) {
          if (err) throw err;
          console.log("done", data);
          console.log("https://s3-ap-southeast-1.amazonaws.com/" + bucket + '/' + random_name);
        })

    });



    busboy.on('finish', function() {
      res.send("That's all folks!");
    });
于 2015-11-22T10:02:34.510 回答