We are trying to build an image editor in Blazor WASM. The source image is a 3rd party site, so when we use HttpClient to retrieve the data, we are hit with a CORS error.
So, we setup a "proxy" (not exactly a proxy), but an ASP.NET API that would retrieve the image and then stream it, to avoid the CORS problem. But now, because this is AWS Lambda, we are running into the AWS Lambda payload limit.
We then tried HttpRequestMessage.SetBrowserRequestMode(BrowserRequestMode.NoCors)
and ran into this: https://github.com/dotnet/aspnetcore/issues/24080
We are seemingly running out options.
My next attempt I would like to do is allow the image to flow naturally to <img>
from the 3rd party hosting site. This seems to work as the browser does NOT throw a CORS error on the retrieving the data from a 3rd party site.
Is there anyway in Blazor WASM to "steal" the image data from the <img>
and put it into a byte array or stream so that we have the image data to work with?
Any other ideas on how to load a large image file into a stream or byte array given the above constraints?
I've also considered chunking it, but that seems like a big hassle.