From b3e37c7ea4e3b997c9bc918a116134527dc92c97 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 26 Sep 2023 14:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95oss=20=20=E6=94=B9=E4=B8=BA1?= =?UTF-8?q?=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Controllers/ExtraController.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index 3722593db..b245633d8 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -148,12 +148,15 @@ namespace IRaCIS.Api.Controllers IClientProfile profile = DefaultProfile.GetProfile("cn-shanghai", configuration["AliyunOSS:accessKeyId"], configuration["AliyunOSS:accessKeySecret"]); DefaultAcsClient client = new DefaultAcsClient(profile); + + + // 创建一个STS请求 AssumeRoleRequest request = new AssumeRoleRequest { RoleArn = "acs:ram::1899121822495495:role/oss-upload", // 角色ARN,需要替换为你的角色ARN - RoleSessionName = "session-name", // 角色会话名称,可自定义 - DurationSeconds = 3600, // 令牌有效期(单位:秒),这里设置为1小时 + RoleSessionName = $"session-name-{Guid.NewGuid()}", // 角色会话名称,可自定义 + DurationSeconds = 60, // 令牌有效期(单位:秒),这里设置为1小时 };