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
feita há 5 anos1018 visualizações
1 Resposta
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 há 5 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas