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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン