Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!