From cc7eb0553e93844be984045bca3e335d4ae0dede Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 04 七月 2022 10:46:25 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wjc' into release0123
---
HDL_ON/Common/ImageUtlis.cs | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/HDL_ON/Common/ImageUtlis.cs b/HDL_ON/Common/ImageUtlis.cs
index 918483d..3b3a486 100644
--- a/HDL_ON/Common/ImageUtlis.cs
+++ b/HDL_ON/Common/ImageUtlis.cs
@@ -147,9 +147,9 @@
{
var requestJson = HttpUtil.GetSignRequestJson(uploadImageObj);
var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_UploadImage, requestJson);
- if(revertObj.Code == StateCode.SUCCESS)
+ if (revertObj.Code == StateCode.SUCCESS)
{
- if(revertObj.Data != null)
+ if (revertObj.Data != null)
{
return revertObj.Data.ToString();
}
@@ -440,7 +440,7 @@
try
{
if (string.IsNullOrEmpty(imageKey)) return null;
-
+
byte[] imageBytes;
if (!ignoreCache && Exists(imageKey))
{
@@ -451,12 +451,12 @@
{
//浜戠涓嬭浇
imageBytes = GetImageDownloadUrlWithRegionUrl(imageKey, regionUrl);
- if(imageBytes != null)
+ if (imageBytes != null)
{
//淇濆瓨鍒版湰鍦�
WriteFileByBytes(imageKey, imageBytes);
}
-
+
}
return imageBytes;
}
@@ -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