Cách sửa 'Lỗi: quá nhiều dữ liệu' của archiver.js trong Nodejs


0

Khi tôi bắt đầu tải xuống các tệp từ S3 và nén chúng nhanh chóng, tôi nhận được 'Lỗi: quá nhiều dữ liệu' khi có ít nhất một tệp lớn hơn 10GB. Nhưng đôi khi tôi cần tải xuống các tệp lớn hơn 10GB và nén chúng cùng với các tệp khác.

Tôi đoán, nó có một cái gì đó để làm với dòng hmac được xây dựng. Đây là thông báo lỗi đầy đủ:

Lỗi: quá nhiều dữ liệu tại Confirm._final (/node_modules/hmac-stream/verify.js:120:17) tại callFinal (/node_modules/readable-stream/lib/_stream_writable.js:601:10) tại _combinedTickCallback (nội bộ / process / next_tick.js: 139: 11) tại process._tickDomainCallback (nội bộ / process / next_tick.js: 219: 9)

Đây là cách thực hiện của tôi:

res.header({
    'Content-Type': 'application/x-zip',
    'Content-Length': totalSize,
    'Content-disposition': `attachment; filename=${UUID}.zip`,
    'Transfer-Encoding': 'chunked'
});

const archive = archiver('zip', {
    zlib: {level: 0}
});

archive.pipe(res.status(200));
let fileCounter = 0;

async.forEachSeries(fileKeys, function(file, callback) {
    console.log(file);
    const data = s3.getObject({Bucket: config.aws.bucket, Key: file}).createReadStream();
    archive.append(data.pipe(cryptoStream.decrypt(KEY)), {name: fileNames[fileCounter]});
    fileCounter++;
    callback();
}, function(err) {
    if (err) return next(err);
    archive.finalize(function(err) {
        if (err) throw err;
     });
});

archive.on('error', function(err) {
    throw err;
});

archive.on('end', function(){
    res.end();
});
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.