代码修改
parent
a2c35ba83d
commit
6b6ab9e406
|
@ -227,6 +227,8 @@ namespace IRaCIS.Core.API.Controllers
|
|||
_repository = repository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost, Route("Study/PreArchiveStudy")]
|
||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||
public async Task<IResponseOutput> PreArchiveStudy(PreArchiveStudyCommand preArchiveStudyCommand,
|
||||
|
@ -262,6 +264,12 @@ namespace IRaCIS.Core.API.Controllers
|
|||
}
|
||||
|
||||
|
||||
//public string UploadOOSTest(string filePath, string route)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>Dicom 归档</summary>
|
||||
[HttpPost, Route("Study/ArchiveStudy")]
|
||||
[DisableFormValueModelBinding]
|
||||
|
|
|
@ -11,6 +11,13 @@
|
|||
"Hangfire": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Hangfire_IRaCIS;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
|
||||
|
||||
},
|
||||
|
||||
"AliyunOSS": {
|
||||
"endpoint": "https://zyypacs-code.oss-cn-shanghai.aliyuncs.com",
|
||||
"accessKeyId": "mpXG7Nu6zTpsDrI1",
|
||||
"accessKeySecret": "yNINcEb099SkNfF6vYKaoP8TZNI3xZ",
|
||||
"bucketName": "zyypacs-code"
|
||||
},
|
||||
"BasicSystemConfig": {
|
||||
|
||||
"OpenUserComplexPassword": false,
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
|
||||
|
||||
using Aliyun.OSS;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Configuration;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace IRaCIS.Core.Application.Helper;
|
||||
|
@ -12,6 +14,39 @@ namespace IRaCIS.Core.Application.Helper;
|
|||
public static class FileStoreHelper
|
||||
{
|
||||
|
||||
public static string UploadOOS(string filePath,string route)
|
||||
{
|
||||
var endpoint = ConfigurationManager.AppSettings["AliyunOSS:endpoint"];
|
||||
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
|
||||
|
||||
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
||||
var accessKeyId = ConfigurationManager.AppSettings["AliyunOSS:accessKeyId"];
|
||||
var accessKeySecret = ConfigurationManager.AppSettings["AliyunOSS:accessKeySecret"];
|
||||
// 填写Bucket名称,例如examplebucket。
|
||||
var bucketName = ConfigurationManager.AppSettings["AliyunOSS:bucketName"];
|
||||
// 填写Object完整路径,完整路径中不能包含Bucket名称,例如exampledir/exampleobject.txt。
|
||||
|
||||
var fileNameList = filePath.Split(',').ToList();
|
||||
var fileName = fileNameList[fileNameList.Count() - 1];
|
||||
|
||||
var objectName = route+ fileName;
|
||||
// 填写本地文件完整路径,例如D:\\localpath\\examplefile.txt。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
|
||||
var localFilename = filePath;
|
||||
// 创建OSSClient实例。
|
||||
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
|
||||
try
|
||||
{
|
||||
// 上传文件。
|
||||
var result = client.PutObject(bucketName, objectName, localFilename);
|
||||
|
||||
return result.ETag;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new BusinessValidationFailedException("上传异常!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//处理文件名 压缩包,或者目录类的 会带上相对路径
|
||||
public static (string TrustedFileNameForFileStorage, string RealName) GetStoreFileName(string fileName,bool isChangeToPdfFormat=false)
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="AutoMapper.Collection.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="BeetleX.BNR" Version="1.0.1" />
|
||||
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.1.0" />
|
||||
|
|
Loading…
Reference in New Issue