private ActionResult <IFormFile> WriteFileToDatabase(IFormFile file) { BinaryReader Br = new BinaryReader(file.OpenReadStream()); Byte[] bytes = Br.ReadBytes((Int32)file.OpenReadStream().Length); string fileLocation = Path.GetFullPath(file.FileName); var doc = new Doc() { Name = file.FileName, Data = bytes, FileSize = file.Length.ToString(), Location = fileLocation }; if (docs.AddNewDoc(doc)) { return(Ok()); } return(BadRequest()); }