简体   繁体   English

存储和检索文件的最佳方法?

[英]Best approach to store and retrieve files?

I'm developing an application using C# 4.0 and SQL Server 2008 R2 Express , my application needs to store and retrieve files (docx, pdf, png) locally and remotely, which approach would be the best? 我正在使用C#4.0SQL Server 2008 R2 Express开发应用程序,我的应用程序需要在本地和远程存储和检索文件(docx,pdf,png),哪种方法最好?

  1. Store the files in separate database (problem: restricted to 10 GB) 将文件存储在单独的数据库中 (问题:限制为10 GB)
  2. Use a windows shared folder (who to do?) 使用Windows共享文件夹 (该怎么办?)
  3. Use an FTP server (which server and library and how to do?) 使用FTP服务器 (哪个服务器和库以及如何做?)

SQL Server supports FILESTREAM , so if you have enough control over the SQL Server install to enable that feature then it seems like a good fit for you. SQL Server支持FILESTREAM ,因此,如果您对SQL Server安装具有足够的控制权以启用该功能,那么它似乎非常适合您。

FILESTREAM integrates the SQL Server Database Engine with an NTFS file system by storing varbinary(max) binary large object (BLOB) data as files on the file system. FILESTREAM通过将varbinary(max)二进制大对象(BLOB)数据存储为文件系统上的文件,将SQL Server数据库引擎与NTFS文件系统集成在一起。 Transact-SQL statements can insert, update, query, search, and back up FILESTREAM data. Transact-SQL语句可以插入,更新,查询,搜索和备份FILESTREAM数据。 Win32 file system interfaces provide streaming access to the data. Win32文件系统接口提供对数据的流式访问。

Files stored directly in the file system with FILESTREAM don't count towards the database size because they aren't stored in the DB. 使用FILESTREAM直接存储在文件系统中的文件不计入数据库大小,因为它们没有存储在数据库中。

To confirm with an official source: https://docs.microsoft.com/en-us/sql/relational-databases/blob/filestream-compatibility-with-other-sql-server-features 确认官方消息: https : //docs.microsoft.com/zh-cn/sql/relational-databases/blob/filestream-compatibility-with-other-sql-server-features

SQL Server Express supports FILESTREAM. SQL Server Express支持FILESTREAM。 The 10-GB database size limit does not include the FILESTREAM data container. 10 GB的数据库大小限制不包括FILESTREAM数据容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM