0

I'm having an issue when I try to upload a file to s3 bucket. According to the error message it is a networking error but I'm not sure why I got this error message. This issue does not happen consistently. Can someone help me with this?

CODE

async uploadReportToS3(data){
    var uploadParams = {
      Bucket: process.env.S3_BUCKET,
      Key: "",
      Body: ""
    }
    let errorMsg = {
      "ERROR": "",
      "exit_code": 1
    }
    var key = "";

    if(data.sub_client && data.sub_client !== ""){
      key = process.env.S3_REPORT_FOLDER + data.client + "/" + data.sub_client + "/" + data.report_name; 
    } else if(data.sub_client == ""){
      key = process.env.S3_REPORT_FOLDER + data.client + "/" + data.report_name; 
    } else if(data.sub_client == null || data.sub_client == undefined){
      errorMsg.ERROR = "MISSING SUB CLIENT";
      let returnMsg = JSON.stringify(errorMsg);
      console.error(returnMsg);
      process.exit(1);
    }
    
    uploadParams.Key = key;
    uploadParams.Body = data.buffer;
  
    await s3.upload(uploadParams, function(error, response){
      if(error){
        errorMsg.ERROR = error;
        let returnMsg = JSON.stringify(errorMsg);
        console.error(returnMsg);
        process.exit(1);
      } else {
        let returndata = {
          "report_date": data.report_date,
          "pdf_path": response.Key,
          "error_code": 0
        }
        let returnedMsg = JSON.stringify(returndata);
        console.log(returnedMsg);
        process.exit(0);
      }
    })
  }

ERROR MESSAGE

"ERROR":{"message":"write EPIPE","errno":-32,"code":"NetworkingError","syscall":"write","region":"us-east-2","hostname":"test.s3.us-east-2.amazonaws.com","retryable":true,"time":"2020-07-06T19:23:36.775Z","statusCode":400}
Tri Vi
  • 33
  • 1
  • 5
  • Does this answer your question? [Amazon S3 EPIPE Error](https://stackoverflow.com/questions/11978672/amazon-s3-epipe-error) – Joao Fernandes Jul 07 '20 at 16:31
  • I don't think the given link is the answer. This issue just happened couple days ago and it only appeared one or two times. – Tri Vi Jul 08 '20 at 15:12
  • Did you manage to fix the issue? If so, please post the solution. Otherwise, improve the question so that it is easier to get an answer. – Joao Fernandes Jul 22 '20 at 15:34

0 Answers0