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

163
Views
Nodejs upload file to S3

I'm using Serverless Framework with AWS Lambda to upload files/images to S3. The data come from a multipart/form-data form so I get file(s) in binary format.

Example of POST request from REST client (Insomnia)

Upload to S3 code :

this.client
    .putObject({
        Bucket: s3bucket,
        Key: s3path,
        Body: Buffer.from(data, 'binary'),
        ContentType: params.mimetype
    })
    .promise();

The problem is files or images uploaded to S3 are corrupted :

The image "http://xxxxx.eu-west-3.amazonaws.com/xxx cannot be displayed because it contains errors.

I already set binaryMediaTypes in my Serverless file config for api gateway :

apiGateway: {
  binaryMediaTypes: ['*/*'],
},

and the same in AWS API Gateway Binary Media Types config, I set * / * when * / * means all media types

API Gateway Config

Have you ever encountered this problem ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. In the integration request check if the content handling: passthrough
  2. Accept the incoming request headers in HTTP Headers section. Refer this

Related issue

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