Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda