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?

1 Risposta
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
con risposta 2 anni fa
  • 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

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande