From 9850e249fc913a65d2124feaa88918681cb44875 Mon Sep 17 00:00:00 2001 From: Pavel Vesely Date: Fri, 15 May 2020 08:20:00 +0200 Subject: [PATCH] File Controller bug --- Oqtane.Server/Controllers/FileController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Oqtane.Server/Controllers/FileController.cs b/Oqtane.Server/Controllers/FileController.cs index 0c30bbdf..0bfe1de2 100644 --- a/Oqtane.Server/Controllers/FileController.cs +++ b/Oqtane.Server/Controllers/FileController.cs @@ -413,8 +413,11 @@ namespace Oqtane.Controllers { _logger.Log(LogLevel.Error, this, LogFunction.Read, "File Does Not Exist {FileId} {FilePath}", id, filepath); HttpContext.Response.StatusCode = 404; - byte[] filebytes = System.IO.File.ReadAllBytes(errorpath); - return File(filebytes, "application/octet-stream", file.Name); + if (System.IO.File.Exists(errorpath)) + { + byte[] filebytes = System.IO.File.ReadAllBytes(errorpath); + return File(filebytes, "application/octet-stream", file.Name); + } } } else @@ -432,6 +435,7 @@ namespace Oqtane.Controllers byte[] filebytes = System.IO.File.ReadAllBytes(errorpath); return File(filebytes, "application/octet-stream", "error.png"); } + return null; } private string GetFolderPath(Folder folder)