直接流上传的文件到数据库表 [英] Streaming uploaded files directly into a database table

查看:201
本文介绍了直接流上传的文件到数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个应用程序,允许用户上传存储数据库表内的附件。这正常工作了好几年,因为它最初是用于短小的图像文件,但现在他们要上传非常大的文件(80MB〜)。这导致服务器内存不足(与上载失败)运行,因为,为了将二进制数据写入到数据库中,我加载整个内容转换成一个字节数组。许多人,即使不是大多数,文件上传网上的例子用这个方法(见的 http://www.aspnettutorials.com/tutorials/database/Save-Img-ToDB-Csharp.aspx 作为一个例子)。

I have several applications that allow users to upload attachments that are stored inside a database table. This has worked fine for several years because it was initially intended for smallish image files, but now they want to upload very large files (~80MB). This is causing the server to run out of memory (and the upload to fail) because, in order to write the binary data to a database, I am loading the entire content into a byte array. Many, if not most, online examples for file uploads use this method (see http://www.aspnettutorials.com/tutorials/database/Save-Img-ToDB-Csharp.aspx as an example).

现在的问题是,我可以以某种方式流二进制内容的数据库,而不是整个内容加载到一个字节数组,然后设置字节数组作为一个参数值?开关基于文件的,以替代基于数据库的存储将是在这一点上什么大不了的事......

Now, the question is, can I somehow stream the binary content to the database instead of loading the entire content into a byte array and then setting the byte array as a parameterized value? Switching to file-based instead of database-based storage would be a big deal at this point...

推荐答案

也许这文章可以指向您正确的方向。

Maybe this article can point you to the right direction.

这篇关于直接流上传的文件到数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆