fix: 增加日志

This commit is contained in:
2026-06-29 13:56:38 +08:00
parent 5c8d7d1b7a
commit 058b8937c1

View File

@@ -19,6 +19,7 @@ public class AliyunClient : IAliyunClient
{ {
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly ILogger<AliyunClient> _logger;
private readonly string _accessKeyId; private readonly string _accessKeyId;
private readonly string _accessKeySecret; private readonly string _accessKeySecret;
@@ -29,7 +30,7 @@ public class AliyunClient : IAliyunClient
{ {
_httpClientFactory = httpClientFactory; _httpClientFactory = httpClientFactory;
_configuration = configuration; _configuration = configuration;
_logger = logger;
_accessKeyId = "LTAI5tAqyWKcBcSvzpc1ZM72"; _accessKeyId = "LTAI5tAqyWKcBcSvzpc1ZM72";
_accessKeySecret = "YZMSqsmMGlGZuHw5WU2tqt0mmIBX6h"; _accessKeySecret = "YZMSqsmMGlGZuHw5WU2tqt0mmIBX6h";
} }
@@ -70,13 +71,14 @@ public class AliyunClient : IAliyunClient
var url = $"https://{Endpoint}/?Signature={PercentEncode(signature)}"; var url = $"https://{Endpoint}/?Signature={PercentEncode(signature)}";
var bodyString = BuildBodyString(parameters); var bodyString = BuildBodyString(parameters);
using var fallbackClient = _httpClientFactory == null ? new HttpClient() : null; var client = _httpClientFactory.CreateClient();
var client = _httpClientFactory?.CreateClient() ?? fallbackClient;
client.DefaultRequestHeaders.Add("Host", Endpoint); client.DefaultRequestHeaders.Add("Host", Endpoint);
var content = new StringContent(bodyString, Encoding.UTF8, "application/x-www-form-urlencoded"); var content = new StringContent(bodyString, Encoding.UTF8, "application/x-www-form-urlencoded");
var response = await client.PostAsync(url, content); var response = await client.PostAsync(url, content);
var rawResponse = await response.Content.ReadAsStringAsync(); var rawResponse = await response.Content.ReadAsStringAsync();
_logger.LogInformation("Aliyun Id3MetaVerify response:{UserName} , {RawResponse}", userName, rawResponse);
return ParseResponse(rawResponse); return ParseResponse(rawResponse);
} }