The WebApi template already ships with an S3 proxy controller. Tweaking this slightly allowed me to stream or download the image:
The issue I ran into was accessing images via the endpoint you then get in API Gateway – images were getting encoded so wouldn’t render in the browser.
The solution:
- In the settings for your api gateway, add the Binary Media Type: */*
- On the {proxy+} method ‘Method Response’ add a 200 response header and add a header Content-Type. Finally publish your api
The second step here may not be necessary but I found the */* didn’t kick in until I made the change.
Original article was posted on Boro2g Blog: Serving images through AWS API Gateway