如何从Blazor Wasm的第三方网站检索图像流?
我们正在尝试在Blazor Wasm构建图像编辑器。 源图像是第三方站点,因此,当我们使用httpclient检索数据时,我们会遇到CORS错误。
因此,我们设置了一个“代理”(不完全是代理),而是一个将检索图像然后流式传输的ASP.NET API,以避免CORS问题。但是现在,由于这是AWS lambda,所以我们遇到了AWS lambda有效载荷限制。
然后,我们尝试了httprequestmessage.setBrowserRequestMode(browserrequestmode.nocors)
,然后跑入: https://github.com/dotnet/aspnetcore/issues/24080
我们似乎正在用完选项。
我想做的下一个尝试是允许图像自然流到第三方托管站点的< img>
。这似乎是有效的,因为浏览器不会在第三方网站检索数据上丢下CORS错误。
无论如何,Blazor Wasm是否有从< img>
中“窃取”图像数据并将其放入字节数组或流中,以便我们可以使用图像数据?
关于如何将大图像文件加载到流或字节数组给定上述约束的任何其他想法?
我还考虑过块,但这似乎很麻烦。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论