BLOB、流、字节数组和 WCF

发布于 2024-10-27 09:33:21 字数 312 浏览 1 评论 0原文

我正在开发一个有两层的图像处理服务。顶层是基于 REST 的 WCF 服务,它接受图像上传、处理并将其保存到文件系统。由于我的顶层没有任何直接的数据库访问权限(根据设计),我需要将图像传递到具有数据库访问权限的应用程序层(WsHTTPBinding WCF)。就目前而言,图像的大小最大可达 2MB,我正在尝试找出通过网络传输数据的最佳方法。

我目前正在将图像数据作为字节数组发送,并且该对象必须至少暂时存储在内存中,以便写入数据库(在本例中为 MySQL 服务器),所以我不知道使用Stream 将有助于消除潜在的内存问题,或者如果我无论做什么都必须处理可能填满内存的问题。还是我只是想多了?

I'm working on an image processing service that has two layers. The top layer is a REST based WCF service that takes the image upload, processes and the saves it to the file system. Since my top layer doesn't have any direct database access (by design) I need to pass the image to my application layer (WsHTTPBinding WCF) which does have database access. As it stands right now, the images can be up to 2MB in size and I'm trying to figure out the best way to transport the data across the wire.

I currently am sending the image data as a byte array and the object will have to be stored in memory at least temporarily in order to be written out to the database (in this case, a MySQL server) so I don't know that using a Stream would help eliminate the potential memory issues or if I am going to have to deal with potentially filling up my memory no matter what I do. Or am I just over thinking this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独木成林 2024-11-03 09:33:21

查看此 MSDN 文章的流数据部分:大数据和流

我已经使用所描述的确切方法成功上传大型文档,甚至从 WCF 服务流式传输视频内容。关键是在消息契约中传递 Stream 对象,并在客户端和服务配置中将 TransferMode 设置为 Streaming。

我看到这篇文章 关于有效地将流推送到 MySQL,希望这能让您指明正确的方向。

Check out the Streaming Data section of this MSDN article: Large Data and Streaming

I've used the exact method described to successfully upload large documents and even stream video contents from a WCF service. The keys are to pass a Stream object in the message contract and setting the transferMode to Streaming in the client and service configuration.

I saw this post regarding efficiently pushing that stream into MySQL, hopefully that gets you pointed in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文