相关疑难解决方法(0)

使用Lambda Node从S3上的文件创建S3上的zip文件

我需要创建一个Zip文件,其中包含位于我的s3存储桶中的一系列文件(视频和图像).

目前使用我的代码的问题是我很快就达到了Lambda的内存限制.

async.eachLimit(files, 10, function(file, next) {
    var params = {
        Bucket: bucket, // bucket name
        Key: file.key
    };
    s3.getObject(params, function(err, data) {
        if (err) {
            console.log('file', file.key);
            console.log('get image files err',err, err.stack); // an error occurred
        } else {
            console.log('file', file.key);
            zip.file(file.key, data.Body);
            next();
        }
    });
}, 
function(err) {
    if (err) {
        console.log('err', err);
    } else {
        console.log('zip', zip);
        content = zip.generateNodeStream({
            type: 'nodebuffer',
            streamFiles:true
        });
        var params = {
            Bucket: bucket, // name of dest bucket
            Key: 'zipped/images.zip', …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services node.js aws-lambda

17
推荐指数
3
解决办法
9814
查看次数