Compare commits
No commits in common. "d5d728fea6c9e6cab6161ef8a0e13555559ad29b" and "c24adcd09c3b25dc7634390f665bca9e7e90d9c9" have entirely different histories.
d5d728fea6
...
c24adcd09c
|
|
@ -1,22 +1,35 @@
|
||||||
using AlibabaCloud.SDK.Sts20150401;
|
using Aliyun.OSS;
|
||||||
using Aliyun.OSS;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using Amazon;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Minio.DataModel.Args;
|
||||||
|
using Minio;
|
||||||
|
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;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using Minio.ApiEndpoints;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
|
||||||
using Amazon.Runtime;
|
using Amazon.Runtime;
|
||||||
using Amazon.S3;
|
|
||||||
using Amazon.S3.Model;
|
|
||||||
using Amazon.SecurityToken;
|
using Amazon.SecurityToken;
|
||||||
using Amazon.SecurityToken.Model;
|
using Amazon.SecurityToken.Model;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using Amazon;
|
||||||
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
|
using Amazon.S3;
|
||||||
|
using Amazon.S3.Model;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.Extensions.Options;
|
using AlibabaCloud.SDK.Sts20150401;
|
||||||
using Minio;
|
|
||||||
using Minio.DataModel.Args;
|
|
||||||
using System.Reactive.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.SCP;
|
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.SCP
|
||||||
|
{
|
||||||
#region 绑定和返回模型
|
#region 绑定和返回模型
|
||||||
|
|
||||||
[LowerCamelCaseJson]
|
[LowerCamelCaseJson]
|
||||||
|
|
@ -145,7 +158,7 @@ public interface IOSSService
|
||||||
|
|
||||||
public Task DeleteFromPrefix(string prefix);
|
public Task DeleteFromPrefix(string prefix);
|
||||||
|
|
||||||
public ObjectStoreDTO GetObjectStoreTempToken();
|
public Task<ObjectStoreDTO> GetObjectStoreTempToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -162,10 +175,9 @@ public class OSSService : IOSSService
|
||||||
{
|
{
|
||||||
ObjectStoreServiceOptions = options.CurrentValue;
|
ObjectStoreServiceOptions = options.CurrentValue;
|
||||||
|
|
||||||
|
GetObjectStoreTempToken().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder
|
/// oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -176,8 +188,6 @@ public class OSSService : IOSSService
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true)
|
public async Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true)
|
||||||
{
|
{
|
||||||
GetObjectStoreTempToken();
|
|
||||||
|
|
||||||
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}" : $"{oosFolderPath}/{fileRealName}";
|
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{fileRealName}" : $"{oosFolderPath}/{fileRealName}";
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -277,8 +287,6 @@ public class OSSService : IOSSService
|
||||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||||
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true)
|
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true)
|
||||||
{
|
{
|
||||||
GetObjectStoreTempToken();
|
|
||||||
|
|
||||||
var localFileName = Path.GetFileName(localFilePath);
|
var localFileName = Path.GetFileName(localFilePath);
|
||||||
|
|
||||||
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}";
|
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}";
|
||||||
|
|
@ -347,7 +355,6 @@ public class OSSService : IOSSService
|
||||||
|
|
||||||
public async Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath)
|
public async Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath)
|
||||||
{
|
{
|
||||||
GetObjectStoreTempToken();
|
|
||||||
|
|
||||||
ossRelativePath = ossRelativePath.TrimStart('/');
|
ossRelativePath = ossRelativePath.TrimStart('/');
|
||||||
try
|
try
|
||||||
|
|
@ -433,8 +440,6 @@ public class OSSService : IOSSService
|
||||||
|
|
||||||
public async Task<string> GetSignedUrl(string ossRelativePath)
|
public async Task<string> GetSignedUrl(string ossRelativePath)
|
||||||
{
|
{
|
||||||
GetObjectStoreTempToken();
|
|
||||||
|
|
||||||
ossRelativePath = ossRelativePath.TrimStart('/');
|
ossRelativePath = ossRelativePath.TrimStart('/');
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -533,8 +538,6 @@ public class OSSService : IOSSService
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task DeleteFromPrefix(string prefix)
|
public async Task DeleteFromPrefix(string prefix)
|
||||||
{
|
{
|
||||||
GetObjectStoreTempToken();
|
|
||||||
|
|
||||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||||
{
|
{
|
||||||
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||||
|
|
@ -671,9 +674,10 @@ public class OSSService : IOSSService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ObjectStoreDTO GetObjectStoreTempToken()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<ObjectStoreDTO> GetObjectStoreTempToken()
|
||||||
|
{
|
||||||
var ossOptions = ObjectStoreServiceOptions.AliyunOSS;
|
var ossOptions = ObjectStoreServiceOptions.AliyunOSS;
|
||||||
|
|
||||||
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||||
|
|
@ -741,7 +745,7 @@ public class OSSService : IOSSService
|
||||||
DurationSeconds = awsOptions.DurationSeconds // 临时凭证有效期
|
DurationSeconds = awsOptions.DurationSeconds // 临时凭证有效期
|
||||||
};
|
};
|
||||||
|
|
||||||
var assumeRoleResponse = stsClient.AssumeRoleAsync(assumeRoleRequest).Result;
|
var assumeRoleResponse = await stsClient.AssumeRoleAsync(assumeRoleRequest);
|
||||||
|
|
||||||
var credentials = assumeRoleResponse.Credentials;
|
var credentials = assumeRoleResponse.Credentials;
|
||||||
|
|
||||||
|
|
@ -768,3 +772,6 @@ public class OSSService : IOSSService
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue