Browse Source

Merge pull request #1203 from colinin/fix-generate-download-url

fix(oss): 同一文件生成的下载链接应该唯一
pull/1211/head
yx lin 10 months ago
committed by GitHub
parent
commit
641302188c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/OssObjectAppService.cs
  2. 16
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/LINGYUN/Abp/OssManagement/OssObjectClientProxy.Generated.cs
  3. 152
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.HttpApi.Client/ClientProxies/oss-management-generate-proxy.json

4
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<string> 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)
{

16
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<IOssObjectAppService
{ typeof(GetOssObjectInput), input }
});
}
public virtual async Task<string> GenerateUrlAsync(GetOssObjectInput input)
{
return await RequestAsync<string>(nameof(GenerateUrlAsync), new ClientProxyRequestTypeValue
{
{ typeof(GetOssObjectInput), input }
});
}
public virtual async Task<IRemoteStreamContent> DownloadAsync(string urlKey)
{
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadAsync), new ClientProxyRequestTypeValue
{
{ typeof(string), urlKey }
});
}
}

152
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"
}

Loading…
Cancel
Save