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

229
Visualizações
Uploading file to S3 using a custom API and AWS lambda

I am trying to send a file through Postman using the form-data type. The request is sent to AWS Lambda using an API. The request content in the Lambda is corrupted with a lot of question marks in the content.

I would like to convert back to the file from the request content and store the file in S3.

Existing code -

const res = multipart.parse(event, false);
var file = res['File'];
var encodedFile = Buffer.from(file["content"], 'binary');
var encodedFilebs64 = Buffer.from(file["content"], 'binary').toString('base64');
const s3 = new AWS.S3();

const params = {
    Bucket: config.s3Bucket,
    Key: "asset_" + known_asset_id + '.bin',
    Body: encodedFile
};

await s3.upload(params).promise().then(function(data) {
    console.log(`File uploaded successfully. ${data.Location}`);
}, function(err) {
    console.error("Upload failed", err);
});

Response content from Cloudwatch logs - https://i.stack.imgur.com/SvBfF.png

When converting this to binary and comparing, the file is not same as the original file.

It would be helpful if someone could help me construct the file from response and store it in S3.

about 4 years ago · Juan Pablo Isaza
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