I have an ASP.NET MVC project with Entity Framework. My application accepts a file and saves it as byte[]
in my SQL Server Compact database.
When I want to view the uploaded file, I want to transfer it to the normal file format. How is that possible?
This is my upload method
if (Request.Files != null && Request.Files.Count == 1)
{
var file = Request.Files[0];
if (file != null && file.ContentLength > 0)
{
var content = new byte[file.ContentLength];
file.InputStream.Read(content, 0, file.ContentLength);
applicant.CV = content;
db.Applicants.Add(applicant);
db.SaveChanges();
return RedirectToAction("list");
}
}
I have multiple files and for each file I want to be able to download and see them upon clicking a button
It simply required converting bytes to characters
char[] chars = Encoding.Unicode.GetChars(da);
and return a file defining it's type and data to be included