Browse Source

feat(oss): added the feature switch for accessing public files

pull/331/head
cKey 4 years ago
parent
commit
b580dbcc80
  1. 43
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PublicFileAppService.cs
  2. 7
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Features/AbpOssManagementFeatureDefinitionProvider.cs
  3. 5
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Features/AbpOssManagementFeatureNames.cs
  4. 6
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/en.json
  5. 2
      aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/zh-Hans.json

43
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Application/LINGYUN/Abp/OssManagement/PublicFileAppService.cs

@ -1,4 +1,10 @@
namespace LINGYUN.Abp.OssManagement
using LINGYUN.Abp.Features.LimitValidation;
using LINGYUN.Abp.OssManagement.Features;
using System.IO;
using System.Threading.Tasks;
using Volo.Abp.Features;
namespace LINGYUN.Abp.OssManagement
{
public class PublicFileAppService : FileAppServiceBase, IPublicFileAppService
{
@ -10,6 +16,41 @@
{
}
[RequiresFeature(
AbpOssManagementFeatureNames.PublicAccess,
AbpOssManagementFeatureNames.OssObject.UploadFile,
RequiresAll = true)]
public override async Task UploadAsync(UploadFileChunkInput input)
{
await base.UploadAsync(input);
}
[RequiresFeature(
AbpOssManagementFeatureNames.PublicAccess,
AbpOssManagementFeatureNames.OssObject.UploadFile,
RequiresAll = true)]
[RequiresLimitFeature(
AbpOssManagementFeatureNames.OssObject.UploadLimit,
AbpOssManagementFeatureNames.OssObject.UploadInterval,
LimitPolicy.Month)]
public override async Task<OssObjectDto> UploadAsync(UploadFileInput input)
{
return await base.UploadAsync(input);
}
[RequiresFeature(
AbpOssManagementFeatureNames.PublicAccess,
AbpOssManagementFeatureNames.OssObject.DownloadFile,
RequiresAll = true)]
[RequiresLimitFeature(
AbpOssManagementFeatureNames.OssObject.DownloadLimit,
AbpOssManagementFeatureNames.OssObject.DownloadInterval,
LimitPolicy.Month)]
public override async Task<Stream> GetAsync(GetPublicFileInput input)
{
return await base.GetAsync(input);
}
protected override string GetCurrentBucket()
{
return "public";

7
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Features/AbpOssManagementFeatureDefinitionProvider.cs

@ -13,6 +13,13 @@ namespace LINGYUN.Abp.OssManagement.Features
name: AbpOssManagementFeatureNames.GroupName,
displayName: L("Features:OssManagement"));
featureGroup.AddFeature(
name: AbpOssManagementFeatureNames.PublicAccess,
defaultValue: false.ToString(),
displayName: L("Features:DisplayName:PublicAccess"),
description: L("Features:Description:PublicAccess"),
valueType: new ToggleStringValueType(new BooleanValueValidator()));
var ossFeature = featureGroup.AddFeature(
name: AbpOssManagementFeatureNames.OssObject.Default,
defaultValue: true.ToString(),

5
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Features/AbpOssManagementFeatureNames.cs

@ -3,7 +3,10 @@
public class AbpOssManagementFeatureNames
{
public const string GroupName = "AbpOssManagement";
/// <summary>
/// 是否运行未经授权的用户访问公共目录
/// </summary>
public const string PublicAccess = GroupName + ".PublicAccess";
public class OssObject
{

6
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/en.json

@ -33,8 +33,10 @@
"Description:FileLimitLength": "Limit size of uploaded file in MB",
"DisplayName:AllowFileExtensions": "File extension",
"Description:AllowFileExtensions": "List of allowed extensions to upload files, with multiple extensions separated by, don't need a notation",
"Features:FileManagement": "File management",
"Features:DisplayName:FileSystem": "File system",
"Features:OssManagement": "Oss management",
"Features:DisplayName:PublicAccess": "Public Access",
"Features:Description:PublicAccess": "Whether to allow unauthorized users to access public directories",
"Features:DisplayName:OssObject": "Oss Objects",
"Features:DisplayName:DownloadFile": "Download file",
"Features:Description:DownloadFile": "Whether to allow users to download files",
"Features:DisplayName:DownloadLimit": "Limit Of Downloads",

2
aspnet-core/modules/oss-management/LINGYUN.Abp.OssManagement.Domain.Shared/LINGYUN/Abp/OssManagement/Localization/Resources/zh-Hans.json

@ -34,6 +34,8 @@
"DisplayName:AllowFileExtensions": "文件扩展名",
"Description:AllowFileExtensions": "允许的上传文件扩展名列表,多个扩展名以,分隔,无需输入.符号",
"Features:OssManagement": "对象存储",
"Features:DisplayName:PublicAccess": "公共访问",
"Features:Description:PublicAccess": "是否允许未经授权的用户访问公共目录",
"Features:DisplayName:OssObject": "Oss管理",
"Features:DisplayName:DownloadFile": "下载文件",
"Features:Description:DownloadFile": "是否允许用户下载文件",

Loading…
Cancel
Save