我从s3存储桶下载了一个zip文件,然后解压缩了zip文件,最后使用Node JS将一个文件上传到Lambda函数中的s3存储桶.但是我收到了错误
==>错误:EROFS:只读文件系统,打开'./tmp/test.zip'"在完成>请求之前退出流程"
exports.handler = function (callback) {
downloadZipFile(params, downloadPath, function (err) {
if (err) {
callback(err);
} else {
processZipFile(downloadPath, function (err) {
if (err) {
callback(err);
} else {
callback(null);
}
});
}
});
};
function downloadZipFile(params, downloadPath, callback) {
const file = fs.createWriteStream(downloadPath);
s3.getObject(params)
.on('httpData', function (chunk) {
file.write(chunk);
})
.on('success', function () {
callback(null);
})
.on('error', function (err) {
callback(err);
})
.on('complete', function () {
file.end();
})
.send();
}
function processZipFile(filePath) {
const stats = fs.statSync(filePath) …Run Code Online (Sandbox Code Playgroud) 我已将一个zip文件上传到S3存储桶.zip文件上传后,我需要立即触发下面的lambda
函数。请帮助我如何进行
exports.handler = function (event, context) {
MyLambdaFuntion();
}
MyLambdaFuntion()
{
var bucketName = "TestBucket1";
var fileKey = "test.js";
s3.getObject(params, function (err, data) {
if (err)
console.log(err, err.stack);
else {
console.log(data);
}
});
}
Run Code Online (Sandbox Code Playgroud)