上传文件到OSS 需要迁移
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Aliyun.OSS;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -7,6 +8,7 @@ using SharpCompress.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
@@ -85,9 +87,13 @@ namespace IRaCIS.Core.Application.Helper
|
||||
|
||||
public interface IOSSService
|
||||
{
|
||||
public string UploadToOSS(Stream fileStream, string oosFolderPath, string fileRealName);
|
||||
public string UploadToOSS(string localFilePath, string oosFolderPath);
|
||||
|
||||
public void DownLoadFromOSS(string ossRelativePath, string localFilePath);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class OSSService : IOSSService
|
||||
{
|
||||
|
||||
@@ -107,6 +113,34 @@ namespace IRaCIS.Core.Application.Helper
|
||||
|
||||
}
|
||||
|
||||
public string UploadToOSS(Stream fileStream, string oosFolderPath,string fileRealName)
|
||||
{
|
||||
|
||||
var ossRelativePath = oosFolderPath + "/" + fileRealName;
|
||||
|
||||
try
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
fileStream.CopyTo(memoryStream);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// 上传文件
|
||||
var result = _ossClient.PutObject(_OSSConfig.BucketName, ossRelativePath, memoryStream);
|
||||
}
|
||||
|
||||
|
||||
return ossRelativePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new BusinessValidationFailedException("oss上传失败" + ex.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public string UploadToOSS(string localFilePath, string oosFolderPath)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
private readonly IRepository<ClinicalDataTrialSet> _clinicalDataTrialSet;
|
||||
private readonly IRepository<TrialQCQuestionAnswer> _trialQCQuestionAnswerRepository;
|
||||
private readonly IRepository<TrialQCQuestion> _trialQCQuestionRepository;
|
||||
private readonly IRepository<ConsistencyCheckFile> _consistencyCheckFileRepository;
|
||||
private readonly IRepository<InspectionFile> _consistencyCheckFileRepository;
|
||||
|
||||
private IReadingImageTaskService _IReadingImageTaskService;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
IRepository<TrialQCQuestionAnswer> trialQCQuestionAnswerRepository,
|
||||
IRepository<TrialQCQuestion> trialQCQuestionRepository,
|
||||
IReadingImageTaskService IReadingImageTaskService,
|
||||
IRepository<ConsistencyCheckFile> consistencyCheckFileRepository
|
||||
IRepository<InspectionFile> consistencyCheckFileRepository
|
||||
)
|
||||
{
|
||||
this._IReadingImageTaskService = IReadingImageTaskService;
|
||||
@@ -851,7 +851,7 @@ namespace IRaCIS.Core.Application.Image.QA
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<GetConsistencyCheckFileDto>> GetConsistencyCheckFile(GetConsistencyCheckFileInDto indto)
|
||||
{
|
||||
var query = _repository.Where<ConsistencyCheckFile>(t => t.TrialId == indto.TrialId)
|
||||
var query = _repository.Where<InspectionFile>(t => t.TrialId == indto.TrialId)
|
||||
.ProjectTo<GetConsistencyCheckFileDto>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await query.ToPagedListAsync(indto.PageIndex, indto.PageSize, "CreateTime", false);
|
||||
|
||||
@@ -494,7 +494,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
;
|
||||
|
||||
// 一致性核查文件
|
||||
CreateMap<ConsistencyCheckFile, GetConsistencyCheckFileDto>()
|
||||
CreateMap<InspectionFile, GetConsistencyCheckFileDto>()
|
||||
.ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.User.FirstName + "/" + t.User.LastName));
|
||||
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ namespace IRaCIS.Application.Services
|
||||
|
||||
await _repository.BatchDeleteAsync<CheckChallengeDialog>(o => o.SubjectVisit.TrialId == trialId);
|
||||
await _repository.BatchDeleteAsync<ClinicalDataTrialSet>(o => o.TrialId == trialId);
|
||||
await _repository.BatchDeleteAsync<ConsistencyCheckFile>(o => o.TrialId == trialId);
|
||||
await _repository.BatchDeleteAsync<InspectionFile>(o => o.TrialId == trialId);
|
||||
await _repository.BatchDeleteAsync<CriterionNidusSystem>(o => o.TrialReadingCriterion.TrialId == trialId);
|
||||
await _repository.BatchDeleteAsync<DataInspection>(o => o.TrialId == trialId);
|
||||
await _repository.BatchDeleteAsync<DicomStudy>(t => t.TrialId == trialId);
|
||||
|
||||
Reference in New Issue
Block a user