修改上传缓存判断
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
2898c0380f
commit
f732edfc6f
|
@ -34,6 +34,7 @@ using DocumentFormat.OpenXml.Spreadsheet;
|
|||
using AutoMapper.QueryableExtensions;
|
||||
using NetTopologySuite.Algorithm;
|
||||
using ZiggyCreatures.Caching.Fusion;
|
||||
using AlibabaCloud.SDK.Sts20150401;
|
||||
|
||||
namespace IRaCIS.Api.Controllers
|
||||
{
|
||||
|
@ -354,6 +355,44 @@ namespace IRaCIS.Api.Controllers
|
|||
}
|
||||
|
||||
}
|
||||
[HttpGet("user/getUploadTempToken")]
|
||||
public IResponseOutput GetUploadTempToken([FromServices] IOptionsMonitor<AliyunOSSOptions> options)
|
||||
{
|
||||
var ossOptions = options.CurrentValue;
|
||||
|
||||
var client = new Client(new AlibabaCloud.OpenApiClient.Models.Config()
|
||||
{
|
||||
AccessKeyId = ossOptions.accessKeyId,
|
||||
AccessKeySecret = ossOptions.accessKeySecret,
|
||||
Endpoint = "sts.cn-hangzhou.aliyuncs.com"
|
||||
});
|
||||
|
||||
var assumeRoleRequest = new AlibabaCloud.SDK.Sts20150401.Models.AssumeRoleRequest();
|
||||
// 将<YOUR_ROLE_SESSION_NAME>设置为自定义的会话名称,例如oss-role-session。
|
||||
assumeRoleRequest.RoleSessionName = $"session-name-{NewId.NextGuid()}";
|
||||
// 将<YOUR_ROLE_ARN>替换为拥有上传文件到指定OSS Bucket权限的RAM角色的ARN。
|
||||
assumeRoleRequest.RoleArn = ossOptions.roleArn;
|
||||
assumeRoleRequest.DurationSeconds = 3600;
|
||||
var runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
|
||||
var response = client.AssumeRoleWithOptions(assumeRoleRequest, runtime);
|
||||
var credentials = response.Body.Credentials;
|
||||
|
||||
return ResponseOutput.Ok(new
|
||||
{
|
||||
AccessKeyId = credentials.AccessKeyId,
|
||||
AccessKeySecret = credentials.AccessKeySecret,
|
||||
Expiration = credentials.Expiration,
|
||||
SecurityToken = credentials.SecurityToken,
|
||||
|
||||
|
||||
Region = ossOptions.region,
|
||||
BucketName = ossOptions.bucketName,
|
||||
ViewEndpoint = ossOptions.viewEndpoint,
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("user/GenerateSTS")]
|
||||
public IResponseOutput GenerateSTS([FromServices] IOptionsMonitor<AliyunOSSOptions> options)
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.1.4" />
|
||||
<PackageReference Include="aliyun-net-sdk-sts" Version="3.1.2" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
|
||||
|
|
|
@ -789,7 +789,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
var result = new VerifyStudyUploadResult();
|
||||
|
||||
if (_fusionCache.GetOrDefault<Guid>(CacheKeys.TrialStudyUidUploading(trialId, studyInstanceUid)) != _userInfo.Id)
|
||||
if (_fusionCache.GetOrDefault<Guid>(CacheKeys.TrialStudyUidUploading(trialId, studyInstanceUid)) != _userInfo.Id
|
||||
&& _fusionCache.GetOrDefault<Guid>(CacheKeys.TrialStudyUidUploading(trialId, studyInstanceUid)) != Guid.Empty)
|
||||
{
|
||||
|
||||
result.AllowUpload = false;
|
||||
|
|
Loading…
Reference in New Issue