Commit c9a9c202 by 何阳

NEW:1. 修复了人脸图片拉取,后端模板没有替换的问题

parent f87cba62
...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; ...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")] [assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.1")] [assembly: AssemblyFileVersion("1.0.0.2")]
...@@ -71,9 +71,15 @@ namespace FaceServer.Server ...@@ -71,9 +71,15 @@ namespace FaceServer.Server
} }
public static async Task<Result<byte[], string>> GetImage(string imageUrl) public static async Task<Result<byte[], string>> GetImage(string imageUrl)
{ {
var respond = await client.GetAsync(imageUrl); var baseUrl = new Uri(Config.BaseUrl);
if (imageUrl.Contains("{host}"))
{
imageUrl = imageUrl.Replace("{host}", baseUrl.Authority);
}
try
{
var respond = await client.GetAsync(imageUrl);
if (respond.StatusCode != System.Net.HttpStatusCode.OK) if (respond.StatusCode != System.Net.HttpStatusCode.OK)
{ {
var rawError = await respond.Content.ReadAsStringAsync(); var rawError = await respond.Content.ReadAsStringAsync();
...@@ -84,6 +90,13 @@ namespace FaceServer.Server ...@@ -84,6 +90,13 @@ namespace FaceServer.Server
var imageBytes = await respond.Content.ReadAsByteArrayAsync(); var imageBytes = await respond.Content.ReadAsByteArrayAsync();
return imageBytes; return imageBytes;
} }
catch (Exception ex)
{
Log.Error(ex, $"下载图片失败:{imageUrl}");
return $"下载图片失败:{imageUrl}";
}
}
public static async Task<Result<OssFile,string>> QueryFileAsync(User usr) public static async Task<Result<OssFile,string>> QueryFileAsync(User usr)
{ {
Log.Information($"查询{usr.Name} 照片"); Log.Information($"查询{usr.Name} 照片");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment