This commit is contained in:
owenchen committed 2026-10-18 08:55:07 +08:00
1 parent 59ec58a1eb
commit 53184877cd
3 files changed
+20 -1

No files matched your search

@@ -1167,8 +1167,19 @@ namespace CloudBuilder.Master.Service
using var client = new System.Net.Http.HttpClient();
client.Timeout = TimeSpan.FromSeconds(ServiceSettingsPolicy.GetIdCardOcrTimeoutSeconds(service));
//识别服务已启用 Bearer Token 鉴权(appsettings 配置 API_TOKENS 中 win-service 的 Token)
var apiKey = ServiceSettingsPolicy.GetIdCardOcrApiKey(service);
if (!string.IsNullOrWhiteSpace(apiKey))
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", apiKey);
using var response = client.PostAsync(apiUrl, form).GetAwaiter().GetResult();
string json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"[UploadIdCardFile] OCR service returned HTTP {(int)response.StatusCode}: {json}");
return data;
}
if (string.IsNullOrWhiteSpace(json)) return data;
using var doc = System.Text.Json.JsonDocument.Parse(json);