SQL 文件流和 Coldfusion。将非常大的文件读取到变量中
要使用 Coldfusion 将文件插入到文件流中,首先,我必须将文件读入二进制变量,然后必须将其插入到 SQL 中。当我对大文件(1gig)执行此操作时,系统内存不足。
有人能够成功做到这一点吗?
谢谢!
To insert a file into filestream with coldfusion, first, I have to read the file into a binary variable and then I have to insert it into SQL. When I do this with a large file (1gig), the system goes out of memory.
Has anyone been able to do this successfully?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然您可能可以通过增加管理员中为 CF 分配的 RAM 量来实现此目的,但我建议 CF 不是解决此问题的正确工具,并且至少有两种方法可以解决它
。对于您的系统,我会提供以下通用建议:不要将文件(尤其是该大小的文件)存储在数据库中。相反,将对它们的引用存储在数据库中并将它们存储在文件系统上。如果从 Web 访问它们,请将它们存储在 Web 服务器上。
如果您确实需要将它们存储在数据库中,我会将文件移动到 SQL 服务器并在那里执行插入操作,而不是使用 CF 来执行此操作。例如,您可以使用 CF 将文件通过 FTP 传输到 SQL 服务器,然后使用文件位置调用存储过程(或类似的过程)来执行插入。
While you could probably acocmplish this by increasing the amount of RAM allocated for CF in the administrator, I'd suggest that CF is not the right tool for this, and there are at least two ways to get around it..
Without knowing anything about your system, I'd offer this generic advice: don't store files (especially of that size) in the db. Instead, store a reference to them in the DB and store them on the filesystem. If they are being accessed from the web, store them on the web server.
If you really do need to store them in the DB, I would move the file to the SQL server and do the insert there, rather than using CF to do it. You could, for example, use CF to FTP the file to the SQL sever, then call a stored procedure (or similar) with the file location to do the insert.
您不会使用 CF 或任何其他环境将非常大的文件读取到变量中。您使用流。我有一篇文章解释了如何在 C# 中执行此操作,通过 ASP.Net MVC 从 SQL Server 下载和上传图像 以及使用 FILESTREAM 存储选项的后续操作 FILESTREAM MVC:从 SQL Server 下载和上传图像。您可以将相同的技术应用于 CF。
You do not read very large files into variables, using CF or any other environment. You use streams. I have an article explaining how to do this in C#, Download and Upload images from SQL Server via ASP.Net MVC and a follow up that uses the FILESTREAM storage option FILESTREAM MVC: Download and Upload images from SQL Server. You can apply the same techniques to CF.
如果您使用的是较旧版本的 Coldfusion(9 之前)或非 64 位版本,则无论如何您都可能无法为 Coldfusion 服务器分配超过 1.5 GB 的 RAM。您可能需要用 Java 或 C# 编写一个类来处理到数据库的文件流并将其包含为 Java 或 .Net 对象。
我以为 Adobe 已经用 Coldfusion 9 解决了这个问题,但我已经有一段时间没有处理过这么大的文件了。
If you are on an older version of Coldfusion (pre-9) or a non-64 bit version, you may have trouble allocating more than 1.5 GB of ram to the Coldfusion server anyway. You may need to write a class in Java or C# that handles the file stream to database and include it as a Java or .Net object.
I thought that Adobe had addressed this issue with Coldfusion 9, but it has been a while since I have dealt with such large files.