public IActionResult Get(int documentId) { var doc = _documentService.Get(documentId); string path = _documentService.GetFullPath(documentId); if (doc.IsFile) { string contentType = MimeTypeMap.GetMimeType(doc.Name); return(PhysicalFile(path, contentType, doc.Name)); } string zipName = _downloadService.CreateZip(path); byte[] archive = System.IO.File.ReadAllBytes(Path.Combine(_downloadService.GetPathForZip(), zipName)); System.IO.File.Delete(Path.Combine(_downloadService.GetPathForZip(), zipName)); return(File(archive, "application/zip", doc.Name + ".zip")); }