Downloaded files are corrupted when publishing on AWS lambda

0

Hello,
I have .Net core 2.1 project which I am publishing on AWS Lambda, some endpoints I have will get a file from S3 and download it to me.
The thing is when I test locally, the same audio/image file is returned fully to me and I can preview it but when I publish to Lambda I get corrupted files, that I can't preview.

Anything I should configure to fix this?
A code sample:
[HttpGet("person/image")]
public ActionResult<IFormFile> GetPortrait([FromRoute] string imageId)
{
Stream image=GetFromS3(imageId);
return File(image, "image/jpeg"); // returns a FileStreamResult
}

yahya92
preguntada hace 5 años1018 visualizaciones
1 Respuesta
0

Are you returning the results through API Gateway? If so, API Gateway tries to return text or base64 encoded data. Do a web search for 'how to return S3 data from API Gateway' - there are some special API Gateway settings that have to be implemented.

I wanted to return a 1x1 pixel image but instead, I returned a redirect to a public bucket with the file!

MPT.

respondido hace 5 años

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