From 20f099aee8715510406bf46c5e8ff4a8f5d532df Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期三, 02 四月 2025 16:27:19 +0800
Subject: [PATCH] 111

---
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Common/BaiDuFaceHelper.cs |   50 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 12 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs"
index 712efe8..3063316 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_Common/BaiDuFaceHelper.cs"
@@ -17,14 +17,18 @@
         /// <returns></returns>
         public static string GetAccessToken()
         {
-            string url = string.Format("https://aip.baidubce.com/oauth/2.0/token?client_id={0}&client_secret={1}&grant_type={2}", "TqFQHXSNt6Z7cPQ4vDBfBNjq", "0cli6I6s8JFz3qM1Czi5ciRpDqrJuVvm", "client_credentials");
-            string returnStr = BDWebRequest(url, "", "POST");
+            //string url = string.Format("https://aip.baidubce.com/oauth/2.0/token?client_id={0}&client_secret={1}&grant_type={2}", "TqFQHXSNt6Z7cPQ4vDBfBNjq", "0cli6I6s8JFz3qM1Czi5ciRpDqrJuVvm", "client_credentials");
+            //string returnStr = BDWebRequest(url, "", "POST");
 
-            NLog.LogManager.GetCurrentClassLogger().Trace("鐧惧害浜鸿劯璇嗗埆杩斿洖锛�" + returnStr);
-            BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr);
-          token.getdate = DateTime.Now.ToString();
+            //NLog.LogManager.GetCurrentClassLogger().Trace("鐧惧害浜鸿劯璇嗗埆杩斿洖锛�" + returnStr);
+            //BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr);
+            //token.getdate = DateTime.Now.ToString();
 
-            return token.access_token;
+            //return token.access_token;
+
+
+            var str = "24.83aee44079e5a27530bc72d5ec7049a3.2592000.1746152354.282335-118294290";
+            return str;
         }
 
         public static string BDWebRequest(string url, string data, string method)
@@ -113,16 +117,38 @@
         /// </summary>
         /// <param name="path">鏂囦欢璺緞</param>
         /// <returns>base64缂栫爜淇℃伅锛屼笉甯︽枃浠跺ご</returns>
-        public static string GetFileContentAsBase64(string path)
+        //public static string GetFileContentAsBase64(string path)
+        //{
+        //    using (FileStream filestream = new FileStream(path, FileMode.Open))
+        //    {
+        //        byte[] arr = new byte[filestream.Length];
+        //        filestream.Read(arr, 0, (int)filestream.Length);
+        //        string base64 = Convert.ToBase64String(arr);
+        //        return base64;
+        //    }
+        //}
+        public static string GetFileContentAsBase64(string filePath)
         {
-            using (FileStream filestream = new FileStream(path, FileMode.Open))
+            // 鍙繚鐣欐枃浠跺悕锛岄伩鍏嶈矾寰勯敊璇�
+            string fileName = Path.GetFileName(filePath);
+
+            // 鑾峰彇鏂囦欢鐨勫畬鏁磋矾寰�
+            string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "image", fileName);
+
+            if (!File.Exists(fullPath))
+            {
+                throw new FileNotFoundException("鏂囦欢涓嶅瓨鍦細" + fullPath);
+            }
+
+            using (FileStream filestream = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
             {
                 byte[] arr = new byte[filestream.Length];
-                filestream.Read(arr, 0, (int)filestream.Length);
-                string base64 = Convert.ToBase64String(arr);
-                return base64;
+                filestream.Read(arr, 0, arr.Length);
+                return Convert.ToBase64String(arr);
             }
         }
+
+
 
         /// <summary>
         /// 浜鸿劯娉ㄥ唽
@@ -261,7 +287,7 @@
         /// <summary>
         /// 鐢ㄦ埛缁刬d锛屾爣璇嗕竴缁勭敤鎴凤紙鐢辨暟瀛椼�佸瓧姣嶃�佷笅鍒掔嚎缁勬垚锛夛紝闀垮害闄愬埗48B
         /// </summary>
-        public int group_id { get; set; }
+        public string group_id { get; set; }
         /// <summary>
         /// 鐢ㄦ埛id锛堢敱鏁板瓧銆佸瓧姣嶃�佷笅鍒掔嚎缁勬垚锛夛紝瀵瑰簲绯荤粺璐﹀彿
         /// </summary>

--
Gitblit v1.9.3