upload jpeg to lambda

0

Help!

I am uploading an image to lambda and in the body it appears like so (and isBase64 is false):

2022-01-27T08:11:41.076Z	a3fefd6b-fbbd-4d1a-afe1-2459ae090b45	INFO	------WebKitFormBoundarygRtIycxMFrNqXD9C
Content-Disposition: form-data; name="files"; filename="playing.jpg"
Content-Type: image/jpeg

����JFIF��C		

 $.' ",#(7),01444'9=82<.342��C			

Now, the documentation is really not too clear to me when it says:

"To handle binary payloads for AWS Lambda proxy integrations, you must base64-encode your function's response. " (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html). I've tried converting the image below to base64 to no avail. I am not even sure what is this encoding...???

This is what i tried (nodejs 14):

Buffer.from(file.buffer, 'binary').toString('base64'),

The image won't turn up though. Any thoughts?

the first 3 bytes are

00000000: 11101111 10111111 10111101 11101111 10111111 10111101 

or 0xef 0xbf 0xbd...

Any thoughts?

LordVee
preguntada hace 2 años937 visualizaciones
1 Respuesta
0

I had a similar problem, you may need to set BinaryMediaTypes If you are using SAM, add the following settings to your template file :

Globals:
  Api:
    BinaryMediaTypes:
      - image/png
      - image/jpg
      - image/jpeg
``

Or try adding the same in  API Gateway > Settings > Binary Media Types
respondido hace 2 años
  • hi thanks for your answer. I have set it already and i can see data coming in, problem is i don't know what format is data coming as, therefore cannot parse it properly

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas