开发者

MVC and files uploaded by user, where to store files?

I'm having problems with deciding where to store files uploaded by user in my asp.net mvc application.

I've been using asp classic for about 10 years now, and always stored my files on disc at the site, and storing filename and folders in database.

How would you guys approach this problem?

Having them in database, and might get performance issues there? or leave it the way I always done it, and might get problems with "sync" filesystem and db?

I must have some sort of relational info in the database, so I cant store them just on disc

I'm using sql 2005 atm, and I read somewhere that sql 2008 has some sort of datacolumn now that just stores a "pointer" (like the text-datatype) to a file on disc, is that the way to go?

In some way, database is called a database for some reason, so not sure why invent wheel again? :)

Any pointers 开发者_高级运维or ideas would be appreciated, I guess I'm just wondering about problems I might run into if I go with the database-approach

/M


You could use the special App_Data folder to put uploaded files and store the path into the database. If you go with SQL Server 2008 then you could take a look at the FILESTREAM type.


I'm not sure if your web application is load balanced or not, for the file management systems I've built in the past, I have always stored my files on a SAN or a network shared drive so they are accessible to all web/app servers. In addition, rather than storing the files as is, I always change the file name and type before I persist them on the file system (I typically use a GUID as the file name and a random file extension). Lastly, I would store the original file information in the database the files can be moved or copied logically rather than physically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜