diff --git a/24Hour/Controllers/Common/CommonController.cs b/24Hour/Controllers/Common/CommonController.cs index 2e48831..b7a5713 100644 --- a/24Hour/Controllers/Common/CommonController.cs +++ b/24Hour/Controllers/Common/CommonController.cs @@ -2847,34 +2847,44 @@ namespace _24Hour.Controllers.Common [Route("GetImageFiles")] public async Task GetImageFiles(List file) { - //根据输入url获取base64值 - var getstr = (string s) => + try { - var urlpath = s.Replace("/", @"\"); - var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); - if (System.IO.File.Exists(path)) + //根据输入url获取base64值 + var getstr = (string s) => { - return Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); - } - else + var urlpath = s.Replace("/", @"\"); + var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); + if (System.IO.File.Exists(path)) + { + return Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); + } + else + { + return ""; + } + }; + //根据输入url获取文件是否存在 + var getexist = (string s) => { - return ""; - } - }; - //根据输入url获取文件是否存在 - var getexist = (string s) => - { - var urlpath = s.Replace("/", @"\"); - var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); - return System.IO.File.Exists(path); - }; - var data = file.Select(x => new + var urlpath = s.Replace("/", @"\"); + var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" + urlpath); + return System.IO.File.Exists(path); + }; + var data = file.Select(x => new + { + Item = x, + IsExist = getexist(x), + BaseStr = getstr(x) + }); + result.IsSucceed = true; + result.result = data; + + } + catch { - Item=x, - IsExist = getexist(x), - BaseStr = getstr(x) - }); - result.result = data; + result.IsSucceed = true; + result.Message = "系统错误"; + } return result; } ///