1

I have a service that returns image data as base64 encoded text in the body:e.g.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAgAE...etc

However, when we put the service behind the api-gateway behaving as a proxy, the same request will seemingly convert the response to binary

�PNG


IHDR,,y}�u IDA... etc

and has a response header

Content-Type: application/json

The documentation explains how to convert TO binary automatically, but makes no mention on how to leave the response unmodified. I've tried changing contentHandling to CONVERT_TO_TEXT with no success, so I'm wondering if there's another way of having the api gateway not mess with my service responses.

rodmunera
  • 542
  • 1
  • 5
  • 13

1 Answers1

0

I believe you are using the same setup as me;

API gateway 
  V      
Proxy (no contentHandling available)    
  V
Lambda (returns {body: Buffer.toString('base64')})

This solved it for me: https://stackoverflow.com/a/47780921/853015.

Foumpie
  • 1,465
  • 1
  • 14
  • 10