|
|
|
@ -1,7 +1,10 @@ |
|
|
|
using COSXML; |
|
|
|
using COSXML.Common; |
|
|
|
using COSXML.Model.Bucket; |
|
|
|
using COSXML.Model.Object; |
|
|
|
using COSXML.Model.Service; |
|
|
|
using COSXML.Model.Tag; |
|
|
|
using COSXML.Transfer; |
|
|
|
using LINGYUN.Abp.BlobStoring.Tencent; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
@ -384,35 +387,51 @@ internal class TencentOssContainer : OssContainerBase, IOssObjectExpireor |
|
|
|
// throw new ContainerNotFoundException($"Can't not found object {objectName} in container {request.Bucket} with aliyun blob storing");
|
|
|
|
} |
|
|
|
|
|
|
|
var getObjectRequest = new GetObjectBytesRequest(request.Bucket, objectName); |
|
|
|
if (!request.Process.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
getObjectRequest.SetQueryParameter(request.Process, null); |
|
|
|
} |
|
|
|
var objectResult = ossClient.GetObject(getObjectRequest); |
|
|
|
var objectDownloadUrl = ossClient.GetObjectUrl(request.Bucket, objectName); |
|
|
|
|
|
|
|
var client = HttpClientFactory.CreateTenantOssClient(); |
|
|
|
var objectContent = await client.GetStreamAsync(objectDownloadUrl); |
|
|
|
var headObjectRequest = new HeadObjectRequest(request.Bucket, objectName); |
|
|
|
var headObjectResult = ossClient.HeadObject(headObjectRequest); |
|
|
|
|
|
|
|
var ossObject = new OssObject( |
|
|
|
!objectPath.IsNullOrWhiteSpace() |
|
|
|
? objectResult.Key.Replace(objectPath, "") |
|
|
|
: objectResult.Key, |
|
|
|
? headObjectResult.Key.Replace(objectPath, "") |
|
|
|
: headObjectResult.Key, |
|
|
|
request.Path, |
|
|
|
objectResult.eTag, |
|
|
|
headObjectResult.eTag, |
|
|
|
null, |
|
|
|
objectContent.Length, |
|
|
|
headObjectResult.size, |
|
|
|
null, |
|
|
|
new Dictionary<string, string>(), |
|
|
|
objectResult.Key.EndsWith("/")) |
|
|
|
headObjectResult.Key.EndsWith("/")) |
|
|
|
{ |
|
|
|
FullName = objectResult.Key |
|
|
|
FullName = headObjectResult.Key |
|
|
|
}; |
|
|
|
|
|
|
|
if (objectContent.Length > 0) |
|
|
|
if (headObjectResult.size > 0) |
|
|
|
{ |
|
|
|
ossObject.SetContent(objectContent); |
|
|
|
var configuration = await GetConfigurationAsync(); |
|
|
|
// See: https://cloud.tencent.com/document/product/436/47238
|
|
|
|
var preSignatureStruct = new PreSignatureStruct |
|
|
|
{ |
|
|
|
appid = configuration.AppId,//"1250000000"; //腾讯云账号 APPID
|
|
|
|
region = configuration.Region,//"COS_REGION"; //存储桶地域
|
|
|
|
bucket = request.Bucket,//"examplebucket-1250000000"; //存储桶
|
|
|
|
key = objectName, //对象键
|
|
|
|
httpMethod = "GET", //HTTP 请求方法
|
|
|
|
isHttps = true, //生成 HTTPS 请求 URL
|
|
|
|
signDurationSecond = 600, //请求签名时间为600s
|
|
|
|
headers = null, //签名中需要校验的 header
|
|
|
|
queryParameters = null //签名中需要校验的 URL 中请求参数
|
|
|
|
}; |
|
|
|
if (!request.Process.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
preSignatureStruct.queryParameters = new Dictionary<string, string> |
|
|
|
{ |
|
|
|
{ request.Process, "" } |
|
|
|
}; |
|
|
|
} |
|
|
|
var requestSignURL = ossClient.GenerateSignURL(preSignatureStruct); |
|
|
|
var client = HttpClientFactory.CreateTenantOssClient(); |
|
|
|
|
|
|
|
ossObject.SetContent(await client.GetStreamAsync(requestSignURL)); |
|
|
|
} |
|
|
|
|
|
|
|
return ossObject; |
|
|
|
@ -447,6 +466,11 @@ internal class TencentOssContainer : OssContainerBase, IOssObjectExpireor |
|
|
|
return cos.DoesObjectExist(request); |
|
|
|
} |
|
|
|
|
|
|
|
protected async virtual Task<TencentBlobProviderConfiguration> GetConfigurationAsync() |
|
|
|
{ |
|
|
|
return await CosClientFactory.GetConfigurationAsync<AbpOssManagementContainer>(); |
|
|
|
} |
|
|
|
|
|
|
|
protected async virtual Task<CosXml> CreateClientAsync() |
|
|
|
{ |
|
|
|
return await CosClientFactory.CreateAsync<AbpOssManagementContainer>(); |
|
|
|
|