From b4ee7bafc83d9b0b5b7d3cc7c369bd39f796eba5 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 10 六月 2022 09:17:29 +0800 Subject: [PATCH] 代码备份 --- 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