Home
Support Forums

Unable to decode json data if image is too big

website: I cannot share it as it must be kept private
DNS: no dns used
Build: build correctly, works perfectly in local, but doesn’t work in deployed

I’m using netlify function to upload images to Datocms, the image is first encoded in base64 and then sent. After that it is written in the netlify function as temporary file and sent to datocms.
It works fine on local machine, but on deployed if the original image is bigger than 200kb it doesn’t work. To solve this I tried to compress the image, this would again work in local but not when deployed. In all cases if the image is bigger then 200kb I receive this error mesage:

error decoding lambda response: error decoding lambda response: json: cannot unmarshal object into Go struct field .body of type string

I found on other question that this happens when the request isn’t totally a string, but in my case it doesn’t work only if the image is too big.
How can I solve this?

Hi @Fede.leuze,

Could you share a test repo that can reproduce this?