From 4c586bb23cdcae56ae4e4c62e90e148dc10b9d90 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 17 五月 2022 14:19:31 +0800 Subject: [PATCH] Merge branch 'Dev-Branch' into wxr1215 --- HDL_ON/Common/ImageUtlis.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/HDL_ON/Common/ImageUtlis.cs b/HDL_ON/Common/ImageUtlis.cs index 918483d..fe739d5 100644 --- a/HDL_ON/Common/ImageUtlis.cs +++ b/HDL_ON/Common/ImageUtlis.cs @@ -466,6 +466,47 @@ } } + + + /// <summary> + /// 涓嬭浇鐢ㄦ埛澶村儚 + /// </summary> + /// <param name="imageUrl"></param> + /// <param name="ignoreCache">蹇界暐缂撳瓨</param> + /// <param name="regionUrl">鎸囧畾鏈嶅姟鍣ㄥ煙鍚�,浼犵┖涓轰娇鐢ㄥ綋鍓嶇敤鎴峰湴鍧�</param> + /// <returns></returns> + public byte[] DownImageByImageUrl(string imageUrl, bool ignoreCache = false) + { + try + { + if (string.IsNullOrEmpty(imageUrl)) return null; + + byte[] imageBytes; + if (!ignoreCache && Exists(imageUrl)) + { + //鏈湴鏈夌紦瀛� + imageBytes = ReadFile(imageUrl); + } + else + { + //涓嬭浇 + imageBytes = HttpUtil.HttpsDownload(imageUrl); + if (imageBytes != null) + { + //淇濆瓨鍒版湰鍦� + WriteFileByBytes(imageUrl, imageBytes); + } + + } + return imageBytes; + } + catch + { + return null; + } + } + + #endregion } } -- Gitblit v1.8.0