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,18 +71,31 @@ namespace FaceServer.Server ...@@ -71,18 +71,31 @@ 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}"))
if (respond.StatusCode != System.Net.HttpStatusCode.OK)
{ {
var rawError = await respond.Content.ReadAsStringAsync(); imageUrl = imageUrl.Replace("{host}", baseUrl.Authority);
JObject errorObject = (JObject)JsonConvert.DeserializeObject(rawError);
return $"Failed to get image. Code:{errorObject["code"]}, msg:{errorObject["msg"]}";
} }
try
{
var respond = await client.GetAsync(imageUrl);
if (respond.StatusCode != System.Net.HttpStatusCode.OK)
{
var rawError = await respond.Content.ReadAsStringAsync();
JObject errorObject = (JObject)JsonConvert.DeserializeObject(rawError);
return $"Failed to get image. Code:{errorObject["code"]}, msg:{errorObject["msg"]}";
}
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)
{ {
......
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