Skip to content

Commit

Permalink
fix(oss-management): 对空文件流抛出错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
colinin committed Oct 10, 2024
1 parent 8130ce7 commit 6499a44
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -103,6 +104,10 @@ public async virtual Task<IRemoteStreamContent> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,6 +63,10 @@ public override async Task<IRemoteStreamContent> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -35,6 +37,10 @@ public async virtual Task<IRemoteStreamContent> 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);
}
Expand Down

0 comments on commit 6499a44

Please sign in to comment.