I have a asp.net web application using MVC framework, the website allows the registrars to upload some identification documents.
I want the best option to upload these documents :
-
option 1- make a directory in the website folder and save its name in the website web.config file, and save the document file name in my database, so when I want to compose download link I have to combine the root url and the folder name and the
document file name.for example http://www.website.com +
“/DoucmentsFolder” +
“/Documentfilename “ - option 2- save the entire file in the database, and each time I need the file to be downloaded, I have to save it to temporary folder and compose a link to the file, and make sure to delete the file after the user has gotten the file.
- may be there are other suggestion from you .
thanks
The issues with using a FileStore are multiple:
1) Clean-up – you need to leave your file there long enough to be requested and collected, but how do you clean up? If you don’t you run the risk of running out of space. The best way is to have a scheduled task run every so often and delete files older than say an hour – but this is still messy.
2) Doesn’t scale well – unless you write to a SAN – in a web-garden/farm scenario the users request for the file may come to a different server than that which stored it – unless you constrain your system to force all requests from a user to use the same server.
3) Not performant – compared with database operation.
Instead of creating a file and a link to it, return the file as a FileContentResult:
where MyFile looks like:
To Store the File