修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
d5609560e2
commit
5874223866
|
@ -23,6 +23,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||
ILogger<GeneralCalculateService> _logger,
|
||||
|
||||
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
|
||||
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
|
||||
|
@ -764,42 +765,63 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
public async Task<string> FileDownSave(string url, string savePath)
|
||||
{
|
||||
|
||||
|
||||
#region 新
|
||||
try
|
||||
{
|
||||
url= url.Replace(_options.CurrentValue.MinIO.ViewEndpoint, "");
|
||||
if (!string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
string[] strArry = url.Split('/');
|
||||
savePath = savePath + "/" + strArry[strArry.Length - 1];
|
||||
}
|
||||
await _oSSService.DownLoadFromOSSAsync(url, savePath);
|
||||
|
||||
return savePath;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
//try
|
||||
//{
|
||||
// HttpClient httpClient = new HttpClient();
|
||||
// if (!string.IsNullOrWhiteSpace(url))
|
||||
// {
|
||||
// string[] strArry = url.Split('/');
|
||||
// savePath = savePath + "/" + strArry[strArry.Length - 1];
|
||||
// }
|
||||
throw new BusinessValidationFailedException(_localizer["ReadingCalculate_ImageNotExist"]);
|
||||
}
|
||||
|
||||
// var t = httpClient.GetByteArrayAsync(url);
|
||||
// t.Wait();
|
||||
// Stream responseStream = new MemoryStream(t.Result);
|
||||
// Stream stream = new FileStream(savePath, FileMode.Create);
|
||||
// byte[] bArr = new byte[1024];
|
||||
// int size = responseStream.Read(bArr, 0, bArr.Length);
|
||||
// while (size > 0)
|
||||
// {
|
||||
// stream.Write(bArr, 0, size);
|
||||
// size = responseStream.Read(bArr, 0, bArr.Length);
|
||||
// }
|
||||
#endregion
|
||||
|
||||
// stream.Close();
|
||||
// responseStream.Close();
|
||||
|
||||
// return savePath;
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
|
||||
// throw new BusinessValidationFailedException(_localizer["ReadingCalculate_ImageNotExist"]);
|
||||
//}
|
||||
#region 之前
|
||||
try
|
||||
{
|
||||
HttpClient httpClient = new HttpClient();
|
||||
if (!string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
string[] strArry = url.Split('/');
|
||||
savePath = savePath + "/" + strArry[strArry.Length - 1];
|
||||
}
|
||||
|
||||
var t = httpClient.GetByteArrayAsync(url);
|
||||
t.Wait();
|
||||
Stream responseStream = new MemoryStream(t.Result);
|
||||
Stream stream = new FileStream(savePath, FileMode.Create);
|
||||
byte[] bArr = new byte[1024];
|
||||
int size = responseStream.Read(bArr, 0, bArr.Length);
|
||||
while (size > 0)
|
||||
{
|
||||
stream.Write(bArr, 0, size);
|
||||
size = responseStream.Read(bArr, 0, bArr.Length);
|
||||
}
|
||||
|
||||
stream.Close();
|
||||
responseStream.Close();
|
||||
|
||||
return savePath;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw new BusinessValidationFailedException(_localizer["ReadingCalculate_ImageNotExist"]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue