From 6499a4474dccf419c429ba1f53f9c105f42c652c Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 10 Oct 2024 15:35:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(oss-management):=20=E5=AF=B9=E7=A9=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B5=81=E6=8A=9B=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LINGYUN/Abp/OssManagement/FileAppServiceBase.cs | 5 +++++ .../LINGYUN/Abp/OssManagement/PrivateFileAppService.cs | 6 ++++++ .../LINGYUN/Abp/OssManagement/StaticFilesAppService.cs | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/FileAppServiceBase.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/FileAppServiceBase.cs index bef3d3b23..43deed492 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/FileAppServiceBase.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/FileAppServiceBase.cs @@ -6,6 +6,7 @@ using System.IO; using System.Threading.Tasks; using System.Web; +using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Content; using Volo.Abp.Features; @@ -103,6 +104,10 @@ public async virtual Task GetAsync(GetPublicFileInput inpu var ossContainer = OssContainerFactory.Create(); var ossObject = await ossContainer.GetObjectAsync(ossObjectRequest); + if (ossObject == null || ossObject.Content.IsNullOrEmpty()) + { + throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); + } return new RemoteStreamContent(ossObject.Content); } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PrivateFileAppService.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PrivateFileAppService.cs index 1d381a64f..8326d3309 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PrivateFileAppService.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PrivateFileAppService.cs @@ -4,8 +4,10 @@ using Microsoft.Extensions.Caching.Distributed; using System; using System.Collections.Generic; +using System.IO; using System.Threading.Tasks; using System.Web; +using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; using Volo.Abp.Content; @@ -61,6 +63,10 @@ public override async Task GetAsync(GetPublicFileInput inp var ossContainer = OssContainerFactory.Create(); var ossObject = await ossContainer.GetObjectAsync(ossObjectRequest); + if (ossObject == null || ossObject.Content.IsNullOrEmpty()) + { + throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); + } return new RemoteStreamContent(ossObject.Content); } diff --git a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/StaticFilesAppService.cs b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/StaticFilesAppService.cs index 564235bd1..accc38261 100644 --- a/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/StaticFilesAppService.cs +++ b/aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/StaticFilesAppService.cs @@ -1,7 +1,9 @@ using LINGYUN.Abp.Features.LimitValidation; using LINGYUN.Abp.OssManagement.Features; +using System.IO; using System.Threading.Tasks; using System.Web; +using Volo.Abp; using Volo.Abp.Content; using Volo.Abp.Features; @@ -35,6 +37,10 @@ public async virtual Task GetAsync(GetStaticFileInput inpu var ossContainer = OssContainerFactory.Create(); var ossObject = await ossContainer.GetObjectAsync(ossObjectRequest); + if (ossObject == null || ossObject.Content.IsNullOrEmpty()) + { + throw new BusinessException(code: OssManagementErrorCodes.ObjectNotFound); + } return new RemoteStreamContent(ossObject.Content, ossObject.Name); }