From 8a8d1637720ca5783a364772685169bc0b6bd631 Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 17 May 2025 13:18:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(oss):=20=E5=90=8C=E4=B8=80=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=94=9F=E6=88=90=E7=9A=84=E4=B8=8B=E8=BD=BD=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=BA=94=E8=AF=A5=E5=94=AF=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Abp/OssManagement/OssObjectAppService.cs | 4 +- .../OssObjectClientProxy.Generated.cs | 16 ++ .../oss-management-generate-proxy.json | 152 +++++++++++++++++- 3 files changed, 167 insertions(+), 5 deletions(-) diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/OssObjectAppService.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/OssObjectAppService.cs index c4d2b1f66..7d1795ac7 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/OssObjectAppService.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/OssObjectAppService.cs @@ -98,7 +98,9 @@ public class OssObjectAppService : OssManagementApplicationServiceBase, IOssObje [Authorize(AbpOssManagementPermissions.OssObject.Download)] public async virtual Task GenerateUrlAsync(GetOssObjectInput input) { - var cacheKey = JsonSerializer.Serialize(input).ToMd5(); + // 以当前时间戳为盐, 尽量避免同一文件相同的url + var salt = Clock.Now.Ticks.ToString(); + var cacheKey = $"{JsonSerializer.Serialize(input)}{salt}".ToMd5(); var cacheItem = await UrlCache.GetAsync(cacheKey); if (cacheItem == null) { diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/LINGYUN/Abp/OssManagement/OssObjectClientProxy.Generated.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/LINGYUN/Abp/OssManagement/OssObjectClientProxy.Generated.cs index 6c8fc85ef..bc472cc34 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/LINGYUN/Abp/OssManagement/OssObjectClientProxy.Generated.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/LINGYUN/Abp/OssManagement/OssObjectClientProxy.Generated.cs @@ -57,4 +57,20 @@ public partial class OssObjectClientProxy : ClientProxyBase GenerateUrlAsync(GetOssObjectInput input) + { + return await RequestAsync(nameof(GenerateUrlAsync), new ClientProxyRequestTypeValue + { + { typeof(GetOssObjectInput), input } + }); + } + + public virtual async Task DownloadAsync(string urlKey) + { + return await RequestAsync(nameof(DownloadAsync), new ClientProxyRequestTypeValue + { + { typeof(string), urlKey } + }); + } } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/oss-management-generate-proxy.json b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/oss-management-generate-proxy.json index 6349bd2e6..48241ed5b 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/oss-management-generate-proxy.json +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/oss-management-generate-proxy.json @@ -884,6 +884,40 @@ "typeSimple": "LINGYUN.Abp.OssManagement.OssObjectDto" } }, + { + "name": "GenerateUrlAsync", + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "LINGYUN.Abp.OssManagement.GetOssObjectInput, LINGYUN.Abp.OssManagement.Application.Contracts", + "type": "LINGYUN.Abp.OssManagement.GetOssObjectInput", + "typeSimple": "LINGYUN.Abp.OssManagement.GetOssObjectInput", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "System.String", + "typeSimple": "string" + } + }, + { + "name": "DownloadAsync", + "parametersOnMethod": [ + { + "name": "urlKey", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "returnValue": { + "type": "Volo.Abp.Content.IRemoteStreamContent", + "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" + } + }, { "name": "GetContentAsync", "parametersOnMethod": [ @@ -1033,7 +1067,7 @@ "type": "LINGYUN.Abp.OssManagement.OssObjectDto", "typeSimple": "LINGYUN.Abp.OssManagement.OssObjectDto" }, - "allowAnonymous": null, + "allowAnonymous": false, "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" }, "UploadAsyncByInput": { @@ -1203,7 +1237,7 @@ "type": "System.Void", "typeSimple": "System.Void" }, - "allowAnonymous": null, + "allowAnonymous": false, "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" }, "DeleteAsyncByInput": { @@ -1276,7 +1310,7 @@ "type": "System.Void", "typeSimple": "System.Void" }, - "allowAnonymous": null, + "allowAnonymous": false, "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" }, "GetAsyncByInput": { @@ -1349,7 +1383,7 @@ "type": "LINGYUN.Abp.OssManagement.OssObjectDto", "typeSimple": "LINGYUN.Abp.OssManagement.OssObjectDto" }, - "allowAnonymous": null, + "allowAnonymous": false, "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" }, "GetContentAsyncByInput": { @@ -1422,6 +1456,116 @@ "type": "Volo.Abp.Content.IRemoteStreamContent", "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" }, + "allowAnonymous": false, + "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" + }, + "GenerateUrlAsyncByInput": { + "uniqueName": "GenerateUrlAsyncByInput", + "name": "GenerateUrlAsync", + "httpMethod": "GET", + "url": "api/oss-management/objects/generate-url", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "LINGYUN.Abp.OssManagement.GetOssObjectInput, LINGYUN.Abp.OssManagement.Application.Contracts", + "type": "LINGYUN.Abp.OssManagement.GetOssObjectInput", + "typeSimple": "LINGYUN.Abp.OssManagement.GetOssObjectInput", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "Bucket", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Path", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Object", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "MD5", + "jsonName": null, + "type": "System.Boolean", + "typeSimple": "boolean", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + } + ], + "returnValue": { + "type": "System.String", + "typeSimple": "string" + }, + "allowAnonymous": false, + "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" + }, + "DownloadAsyncByUrlKey": { + "uniqueName": "DownloadAsyncByUrlKey", + "name": "DownloadAsync", + "httpMethod": "GET", + "url": "api/oss-management/objects/download/{urlKey}", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "urlKey", + "typeAsString": "System.String, System.Private.CoreLib", + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "urlKey", + "name": "urlKey", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": [], + "bindingSourceId": "Path", + "descriptorName": "" + } + ], + "returnValue": { + "type": "Volo.Abp.Content.IRemoteStreamContent", + "typeSimple": "Volo.Abp.Content.IRemoteStreamContent" + }, "allowAnonymous": null, "implementFrom": "LINGYUN.Abp.OssManagement.IOssObjectAppService" }