Skip to content

AWS Lambda - Supporting binary response in ASP.NET Core 6 #1574

Open
@hugohlln

Description

@hugohlln

Describe the bug

Hello,

I'm creating an ASP.NET Core 6 Rest API running in a lambda behind an API Gateway.
We have somme issues since we would like to return image/webp content and we are not able to do it.

We've seen that a solution exists for ASP.NET Core 2 by calling the following method :
RegisterResponseContentEncodingForContentType("image/webp", ResponseContentEncoding.Base64);

But unforunately we didn't find any information or tutorial to do the same thing using ASP.NET Core 6 cause the lambda support is done as below in the Program.cs file :
builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi);

Is there any way to register image/webp conte type for Base64 transformation in ASP.NET Core 6 using the builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi); method ?

Thanks

Expected Behavior

Be able to register content-types for Base64 transformation in ASP.NET Core 6 Program.cs file

Current Behavior

Unable to register content-types for Base64 transformation in ASP.NET Core 6 Program.cs file

Reproduction Steps

  • Create an ASP.NET Core 6 rest api
  • Add the lambda support in the Program.cs file (builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi);)
  • Return a webp image in your endpoint :
    [HttpGet] public ActionResult GetWebp() { var image = System.IO.File.ReadAllBytes("myImage.webp"); return File(image, "image/webp"); } }

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.AspNetCoreServer.Hosting 1.6.0

Targeted .NET Platform

ASP.NET Core 6.0

Operating System and version

Any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions