From 56dfdc1bf7e7f2bb2456f29c3686dfa935a89e80 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期四, 30 六月 2022 13:59:45 +0800 Subject: [PATCH] 2022年06月30日13:59:08 --- 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