在S3中将文件添加到多个文件夹

时间:2020-06-11 15:08:33

标签: node.js amazon-s3

我想将tempFolder中存在的文件上传到2个不同的s3存储桶中。我的代码按预期工作,可以将多个文件上传到foldername1。 tempFolder有8个文件。我已经将所有8个文件上传到foldername1,并且仅将最后2个文件上传到s3中的我的foldername2。 我该如何添加它们。

function foo() {
    let tempFolder = // folder path 
        return fs.readdirSync(tempFolder ).map((file) => {
            let path = path.join(tempFolder , file);
            let awsPath1 = // s3 bucket foldername1
            let awsPath2 = // s3 bucket foldername2
            let total = fs.statSync(path);
            return s3Upload(awsPath1, () => fs.createReadStream(path), total.size)
                .then(
                    () => {
                        s3Uploaded.push("https://aws.amazon.com/s3/bucketname/" + awsPath);
                    });
        });
}

0 个答案:

没有答案