Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
Lambda Function Error : EROFS: read-only file system, open './tmp/test.zip' Process exited before completing request

I have download a zip file from s3 bucket then extracting the zip file and finally upload one file to s3 bucket in Lambda function using Node JS.But am getting the error

==> Error: EROFS: read-only file system, open './tmp/test.zip' "Process exited before completing> request"

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)
const fileSizeInBytes = stats.size

if (fileSizeInBytes > 0) {

    var srcPath = filePath;
    var destPath = "./tmp";
    targz.decompress({
        src: srcPath,
        dest: destPath

    }, function (err) {
        if (err) {
            console.log(err);
        } else {
            console.log("Done!");

            UploadFile();
        }

    });
  }
}

function UploadFile() {

var body = fs.createReadStream('./tmp/SampleFile.txt')

var srcfileKey = "SampleFile.txt";
// Upload the stream
var s3obj = new AWS.S3({ params: { Bucket: bucketName, Key: srcfileKey } });
s3obj.upload({ Body: body }, function (err, data) {
    if (err) {
        console.log("An error occurred", err);
    }

    console.log("Uploaded the file at", data.Location);
 })
}
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You need to change the file path to just /tmp instead of ./tmp. Lambda only allows you to write to the /tmp directory.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda