public IActionResult Download([FromBody] string[] downloadFiles) { if (downloadFiles == null) { throw new ArgumentNullException(nameof(downloadFiles)); } if (downloadFiles.Length == 0) { return(BadRequest()); } Stream stream; string filename; string?fullPath = null; try { if (downloadFiles.Length == 1) { stream = _uploadSvc.GetFile(User, downloadFiles[0]); filename = Path.GetFileName(downloadFiles[0]); fullPath = _uploadSvc.GetAbsoluteFilePath(User, downloadFiles[0]); } else { stream = _uploadSvc.GetFiles(User, downloadFiles); filename = "download.zip"; } return(File(stream, GetContentType(fullPath ?? filename), filename)); } catch (Exception ex) { _log.LogError(ex, "There was an error trying to download."); return(BadRequest()); } }