Browse Source
Merge pull request #1016 from colinin/fix-oss-empty-stream
fix(oss-management): 对空文件流抛出错误提示
pull/1050/head
yx lin
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
17 additions and
0 deletions
-
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/FileAppServiceBase.cs
-
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PrivateFileAppService.cs
-
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/StaticFilesAppService.cs
|
|
|
@ -6,6 +6,7 @@ using System.ComponentModel.DataAnnotations; |
|
|
|
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 abstract class FileAppServiceBase : OssManagementApplicationServiceBase, |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
@ -4,8 +4,10 @@ using Microsoft.AspNetCore.Authorization; |
|
|
|
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 class PrivateFileAppService : FileAppServiceBase, IPrivateFileAppService |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
@ -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 class StaticFilesAppService : OssManagementApplicationServiceBase, IStati |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
|