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
질문됨 5년 전1018회 조회
1개 답변
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.

답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠