diff --git a/src/admin/api/Admin.Application/Configuration/Storage/Dto/AliStorageSettingEditDto.cs b/src/admin/api/Admin.Application/Configuration/Storage/Dto/AliStorageSettingEditDto.cs index 0f18ed1d3468460a858cb09cebb39443a2860504..e9e51d9886c82e41436e96f6352bd5a3b28ab69d 100644 --- a/src/admin/api/Admin.Application/Configuration/Storage/Dto/AliStorageSettingEditDto.cs +++ b/src/admin/api/Admin.Application/Configuration/Storage/Dto/AliStorageSettingEditDto.cs @@ -13,17 +13,14 @@ namespace Magicodes.Admin.Configuration.Storage.Dto /// /// 是否启用 /// - [Required] public bool IsEnabled { get; set; } /// /// accessKeyId /// - [Required] public string AccessKeyId { get; set; } /// /// accessKeySecret /// - [Required] public string AccessKeySecret { get; set; } /// /// 地域节点 diff --git a/src/admin/api/Admin.Application/Configuration/Storage/Dto/StorageSettingEditDto.cs b/src/admin/api/Admin.Application/Configuration/Storage/Dto/StorageSettingEditDto.cs index f7ee1057a92c12bca70798f2ebee8d6041bd8666..c9e1f55f9b958d581569588423bd17cf6f92b630 100644 --- a/src/admin/api/Admin.Application/Configuration/Storage/Dto/StorageSettingEditDto.cs +++ b/src/admin/api/Admin.Application/Configuration/Storage/Dto/StorageSettingEditDto.cs @@ -11,5 +11,10 @@ namespace Magicodes.Admin.Configuration.Storage.Dto /// 阿里云存储 /// public AliStorageSettingEditDto AliStorageSetting { get; set; } + + /// + /// 腾讯云存储 + /// + public TencentStorageSettingEditDto TencentStorageSetting { get; set; } } } diff --git a/src/admin/api/Admin.Application/Configuration/Storage/Dto/TencentStorageSettingEditDto.cs b/src/admin/api/Admin.Application/Configuration/Storage/Dto/TencentStorageSettingEditDto.cs new file mode 100644 index 0000000000000000000000000000000000000000..ca000a8310e859fb5586bcb89985666ea6517f5f --- /dev/null +++ b/src/admin/api/Admin.Application/Configuration/Storage/Dto/TencentStorageSettingEditDto.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; + +namespace Magicodes.Admin.Configuration.Storage.Dto +{ + public class TencentStorageSettingEditDto + { + /// + /// 是否启用 + /// + public bool IsEnabled { get; set; } + /// + /// 应用ID。 + /// + public string AppId { get; set; } + + /// + /// 秘钥id + /// + public string SecretId { get; set; } + + /// + /// 秘钥Key + /// + public string SecretKey { get; set; } + + /// + /// 区域 + /// + public string Region { get; set; } = "ap-guangzhou"; + + /// + /// 存储桶名称 + /// + public string BucketName { get; set; } + } +} diff --git a/src/admin/api/Admin.Application/Configuration/Storage/StorageSettingAppService.cs b/src/admin/api/Admin.Application/Configuration/Storage/StorageSettingAppService.cs index 3444939aaf89e6c63c5b22dadbb9fc2d19473ec3..158511881e4cc769f4c63eb9b5c56a3e925788ca 100644 --- a/src/admin/api/Admin.Application/Configuration/Storage/StorageSettingAppService.cs +++ b/src/admin/api/Admin.Application/Configuration/Storage/StorageSettingAppService.cs @@ -18,7 +18,19 @@ namespace Magicodes.Admin.Configuration.Storage public async Task GetAllSettings() => new StorageSettingEditDto { - AliStorageSetting = await GetAliStorageSettingsAsync() + AliStorageSetting = await GetAliStorageSettingsAsync(), + TencentStorageSetting = await GetTencentStorageSettingsAsync() + }; + + private async Task GetTencentStorageSettingsAsync() => new TencentStorageSettingEditDto + { + IsEnabled = Convert.ToBoolean( + await SettingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.IsEnabled)), + AppId = await SettingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.AppId), + BucketName = await SettingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.BucketName), + Region = await SettingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.Region), + SecretId = await SettingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.SecretId), + SecretKey = await SettingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.SecretKey), }; private async Task GetAliStorageSettingsAsync() => new AliStorageSettingEditDto @@ -34,6 +46,18 @@ namespace Magicodes.Admin.Configuration.Storage public async Task UpdateAllSettings(StorageSettingEditDto input) { await UpdateAliStorageSettingsAsync(input.AliStorageSetting); + await UpdateTencentStorageSettingsAsync(input.TencentStorageSetting); + + } + + private async Task UpdateTencentStorageSettingsAsync(TencentStorageSettingEditDto input) + { + await SaveSettings(AppSettings.TencentStorageManagement.IsEnabled, input.IsEnabled.ToString()); + await SaveSettings(AppSettings.TencentStorageManagement.AppId, input.AppId); + await SaveSettings(AppSettings.TencentStorageManagement.SecretId, input.SecretId); + await SaveSettings(AppSettings.TencentStorageManagement.SecretKey, input.SecretKey); + await SaveSettings(AppSettings.TencentStorageManagement.Region, input.Region); + await SaveSettings(AppSettings.TencentStorageManagement.BucketName, input.BucketName); } private async Task UpdateAliStorageSettingsAsync(AliStorageSettingEditDto input) diff --git a/src/admin/api/Admin.Host/wwwroot/Localization/Admin/Admin-zh-CN.xml b/src/admin/api/Admin.Host/wwwroot/Localization/Admin/Admin-zh-CN.xml index 75c943d7c2f4fe0592c245d59f35a305367f20aa..af748c97e9ab3db0120f4d3e4abc372d32c71959 100644 --- a/src/admin/api/Admin.Host/wwwroot/Localization/Admin/Admin-zh-CN.xml +++ b/src/admin/api/Admin.Host/wwwroot/Localization/Admin/Admin-zh-CN.xml @@ -883,5 +883,13 @@ + + + + + + + + diff --git a/src/admin/ui/package-lock.json b/src/admin/ui/package-lock.json index 4923c739da4c00ae55b40644b7c8ab56d4a19faa..ea8f078c10d343dbc1fbcd3661fa980486d86620 100644 --- a/src/admin/ui/package-lock.json +++ b/src/admin/ui/package-lock.json @@ -4400,12 +4400,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4420,17 +4422,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4547,7 +4552,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4559,6 +4565,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4573,6 +4580,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4580,12 +4588,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4604,6 +4614,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4684,7 +4695,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4696,6 +4708,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4817,6 +4830,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/admin/ui/src/app/admin/settings/storage-settings.component.html b/src/admin/ui/src/app/admin/settings/storage-settings.component.html index 90340f42c4b32ad4a6de3452c2eef06f19eacbe7..df9b7192675ee84cb4a43c28da3c8f5c3e8a74c6 100644 --- a/src/admin/ui/src/app/admin/settings/storage-settings.component.html +++ b/src/admin/ui/src/app/admin/settings/storage-settings.component.html @@ -41,6 +41,36 @@ + + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
diff --git a/src/admin/ui/src/app/admin/settings/storage-settings.component.ts b/src/admin/ui/src/app/admin/settings/storage-settings.component.ts index 5b6f13a6e852c8398c4f85e97450a44ce84d54bc..8f24043ea04547da281eda8e1e26b2555b48aa34 100644 --- a/src/admin/ui/src/app/admin/settings/storage-settings.component.ts +++ b/src/admin/ui/src/app/admin/settings/storage-settings.component.ts @@ -1,7 +1,7 @@ import { AfterViewChecked, Component, Injector, OnInit } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; -import { StorageSettingEditDto, StorageSettingServiceProxy, AliStorageSettingEditDto } from '@shared/service-proxies/service-proxies'; +import { StorageSettingEditDto, StorageSettingServiceProxy, AliStorageSettingEditDto } from '@shared/service-proxies/service-proxies'; @Component({ templateUrl: './storage-settings.component.html', @@ -9,7 +9,8 @@ import { StorageSettingEditDto, StorageSettingServiceProxy, AliStorageSettingEdi }) export class StorageSettingsComponent extends AppComponentBase implements AfterViewChecked { storageSettings: StorageSettingEditDto; - + initialStorageSettings:StorageSettingEditDto; + test:false; constructor( injector: Injector, private _storageSettingService: StorageSettingServiceProxy @@ -22,6 +23,7 @@ export class StorageSettingsComponent extends AppComponentBase implements AfterV this._storageSettingService.getAllSettings() .subscribe(setting => { this.storageSettings = setting; + this.initialStorageSettings = setting; }); } @@ -31,6 +33,7 @@ export class StorageSettingsComponent extends AppComponentBase implements AfterV } saveAll(): void { + console.log(this.storageSettings); this._storageSettingService.updateAllSettings(this.storageSettings).subscribe(result => { this.notify.info(this.l('SavedSuccessfully')); }); diff --git a/src/admin/ui/src/app/shared/layout/nav/app-navigation.service.ts b/src/admin/ui/src/app/shared/layout/nav/app-navigation.service.ts index 4ff6a1fca9fa6bc7ae395833ad08dc588f10dd5c..dcf541e805c8a2050d3fe87f0c296d2263574523 100644 --- a/src/admin/ui/src/app/shared/layout/nav/app-navigation.service.ts +++ b/src/admin/ui/src/app/shared/layout/nav/app-navigation.service.ts @@ -35,6 +35,7 @@ export class AppNavigationService { new AppMenuItem('Settings', 'Pages.Administration.Tenant.Settings', 'flaticon-settings', '/app/admin/tenantSettings'), new AppMenuItem('PaySettings', 'Pages.Administration.Pay.Settings', 'fa fa-cny', '/app/admin/paySettings'), new AppMenuItem('SmsCodeSettings', 'Pages.Administration.SmsCode.Settings', 'fa fa-comments', '/app/admin/smsCodeSettings'), + new AppMenuItem('StorageSettings', 'Pages.Administration.Storage.Settings', 'fa fa-database', '/app/admin/storageSettings'), new AppMenuItem('MiniProgramSetting', 'Pages.Administration.MiniProgram.Settings', 'fa fa-eraser', '/app/admin/miniProgramSettings') ]), // new AppMenuItem('DemoUiComponents', 'Pages.DemoUiComponents', 'flaticon-shapes', '/app/admin/demo-ui-components'), diff --git a/src/admin/ui/src/shared/service-proxies/service-proxies.ts b/src/admin/ui/src/shared/service-proxies/service-proxies.ts index 137a9b0cc4d575320de7bc84e5b5cd10af1b013a..2869dc9ab9d5e55d49ca6f1cb7ebed63c8c03a74 100644 --- a/src/admin/ui/src/shared/service-proxies/service-proxies.ts +++ b/src/admin/ui/src/shared/service-proxies/service-proxies.ts @@ -20777,6 +20777,7 @@ export interface IAliSmsCodeSettingEditDto { export class StorageSettingEditDto implements IStorageSettingEditDto { aliStorageSetting!: AliStorageSettingEditDto | undefined; + tencentStorageSetting!: TencentStorageSettingEditDto | undefined; constructor(data?: IStorageSettingEditDto) { if (data) { @@ -20790,6 +20791,7 @@ export class StorageSettingEditDto implements IStorageSettingEditDto { init(data?: any) { if (data) { this.aliStorageSetting = data["aliStorageSetting"] ? AliStorageSettingEditDto.fromJS(data["aliStorageSetting"]) : undefined; + this.tencentStorageSetting = data["tencentStorageSetting"] ? TencentStorageSettingEditDto.fromJS(data["tencentStorageSetting"]) : undefined; } } @@ -20803,18 +20805,20 @@ export class StorageSettingEditDto implements IStorageSettingEditDto { toJSON(data?: any) { data = typeof data === 'object' ? data : {}; data["aliStorageSetting"] = this.aliStorageSetting ? this.aliStorageSetting.toJSON() : undefined; + data["tencentStorageSetting"] = this.tencentStorageSetting ? this.tencentStorageSetting.toJSON() : undefined; return data; } } export interface IStorageSettingEditDto { aliStorageSetting: AliStorageSettingEditDto | undefined; + tencentStorageSetting: TencentStorageSettingEditDto | undefined; } export class AliStorageSettingEditDto implements IAliStorageSettingEditDto { - isEnabled!: boolean; - accessKeyId!: string; - accessKeySecret!: string; + isEnabled!: boolean | undefined; + accessKeyId!: string | undefined; + accessKeySecret!: string | undefined; endPoint!: string | undefined; constructor(data?: IAliStorageSettingEditDto) { @@ -20853,12 +20857,68 @@ export class AliStorageSettingEditDto implements IAliStorageSettingEditDto { } export interface IAliStorageSettingEditDto { - isEnabled: boolean; - accessKeyId: string; - accessKeySecret: string; + isEnabled: boolean | undefined; + accessKeyId: string | undefined; + accessKeySecret: string | undefined; endPoint: string | undefined; } +export class TencentStorageSettingEditDto implements ITencentStorageSettingEditDto { + isEnabled!: boolean | undefined; + appId!: string | undefined; + secretId!: string | undefined; + secretKey!: string | undefined; + region!: string | undefined; + bucketName!: string | undefined; + + constructor(data?: ITencentStorageSettingEditDto) { + if (data) { + for (var property in data) { + if (data.hasOwnProperty(property)) + (this)[property] = (data)[property]; + } + } + } + + init(data?: any) { + if (data) { + this.isEnabled = data["isEnabled"]; + this.appId = data["appId"]; + this.secretId = data["secretId"]; + this.secretKey = data["secretKey"]; + this.region = data["region"]; + this.bucketName = data["bucketName"]; + } + } + + static fromJS(data: any): TencentStorageSettingEditDto { + data = typeof data === 'object' ? data : {}; + let result = new TencentStorageSettingEditDto(); + result.init(data); + return result; + } + + toJSON(data?: any) { + data = typeof data === 'object' ? data : {}; + data["isEnabled"] = this.isEnabled; + data["appId"] = this.appId; + data["secretId"] = this.secretId; + data["secretKey"] = this.secretKey; + data["region"] = this.region; + data["bucketName"] = this.bucketName; + return data; + } +} + +export interface ITencentStorageSettingEditDto { + isEnabled: boolean | undefined; + appId: string | undefined; + secretId: string | undefined; + secretKey: string | undefined; + region: string | undefined; + bucketName: string | undefined; +} + export class PagedResultDtoOfTenantListDto implements IPagedResultDtoOfTenantListDto { totalCount!: number | undefined; items!: TenantListDto[] | undefined; diff --git a/src/core/Magicodes.Admin.Core/Configuration/AppSettingProvider.cs b/src/core/Magicodes.Admin.Core/Configuration/AppSettingProvider.cs index 358448c72b3dac6394410bfc05f6bcbcf1e0df0b..4c50b4054502b3c004e04f6baea5001c3ffc0efd 100644 --- a/src/core/Magicodes.Admin.Core/Configuration/AppSettingProvider.cs +++ b/src/core/Magicodes.Admin.Core/Configuration/AppSettingProvider.cs @@ -144,10 +144,19 @@ namespace Magicodes.Admin.Configuration }; private IEnumerable GetStorageCodeSettings() => new[] { + //阿里 new SettingDefinition(AppSettings.AliStorageManagement.IsEnabled, GetFromAppSettings(AppSettings.AliStorageManagement.IsEnabled, "false"),scopes: SettingScopes.Tenant|SettingScopes.Application), new SettingDefinition(AppSettings.AliStorageManagement.AccessKeyId, GetFromAppSettings(AppSettings.AliStorageManagement.AccessKeyId, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), new SettingDefinition(AppSettings.AliStorageManagement.AccessKeySecret, GetFromAppSettings(AppSettings.AliStorageManagement.AccessKeySecret, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), new SettingDefinition(AppSettings.AliStorageManagement.EndPoint, GetFromAppSettings(AppSettings.AliStorageManagement.EndPoint, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), - }; + + //腾讯 + new SettingDefinition(AppSettings.TencentStorageManagement.IsEnabled, GetFromAppSettings(AppSettings.TencentStorageManagement.IsEnabled, "false"),scopes: SettingScopes.Tenant|SettingScopes.Application), + new SettingDefinition(AppSettings.TencentStorageManagement.AppId, GetFromAppSettings(AppSettings.TencentStorageManagement.AppId, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), + new SettingDefinition(AppSettings.TencentStorageManagement.SecretId, GetFromAppSettings(AppSettings.TencentStorageManagement.SecretId, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), + new SettingDefinition(AppSettings.TencentStorageManagement.SecretKey, GetFromAppSettings(AppSettings.TencentStorageManagement.SecretKey, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), + new SettingDefinition(AppSettings.TencentStorageManagement.Region, GetFromAppSettings(AppSettings.TencentStorageManagement.Region, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), + new SettingDefinition(AppSettings.TencentStorageManagement.BucketName, GetFromAppSettings(AppSettings.TencentStorageManagement.BucketName, ""),scopes: SettingScopes.Tenant|SettingScopes.Application), + }; } } diff --git a/src/core/Magicodes.Admin.Core/Configuration/AppSettings.cs b/src/core/Magicodes.Admin.Core/Configuration/AppSettings.cs index 180f1a6b1869e808f374d80a148984fbd05dc42d..f38d15c0a0ec68428363c496b959fde6cb16c140 100644 --- a/src/core/Magicodes.Admin.Core/Configuration/AppSettings.cs +++ b/src/core/Magicodes.Admin.Core/Configuration/AppSettings.cs @@ -108,6 +108,24 @@ namespace Magicodes.Admin.Configuration public const string IsActive = "App.WeChatPayManagement.IsActive"; } + /// + /// Ѷƴ洢 + /// + public static class TencentStorageManagement + { + public const string IsEnabled = "App.TencentStorageManagement.IsEnabled"; + + public const string AppId = "App.TencentStorageManagement.AppId"; + + public const string SecretId = "App.TencentStorageManagement.SecretId"; + + public const string SecretKey = "App.TencentStorageManagement.SecretKey"; + + public const string Region = "App.TencentStorageManagement.Region"; + + public const string BucketName = "App.TencentStorageManagement.BucketName"; + } + /// /// ֧ /// diff --git a/src/unity/Magicodes.Unity/Magicodes.Unity.csproj b/src/unity/Magicodes.Unity/Magicodes.Unity.csproj index cfc4c3f94d289004629fc415a9cd2c71c1264c73..988f3d33b62280a1eff651da10ceadc20e3768db 100644 --- a/src/unity/Magicodes.Unity/Magicodes.Unity.csproj +++ b/src/unity/Magicodes.Unity/Magicodes.Unity.csproj @@ -7,6 +7,7 @@ + diff --git a/src/unity/Magicodes.Unity/Storage/StorageManager.cs b/src/unity/Magicodes.Unity/Storage/StorageManager.cs index 0cced523b1066e8547c22bde746176cb89efe820..3dc35f228cd3be672be22a2bb9536f826cb5d7c0 100644 --- a/src/unity/Magicodes.Unity/Storage/StorageManager.cs +++ b/src/unity/Magicodes.Unity/Storage/StorageManager.cs @@ -6,6 +6,7 @@ using Magicodes.Admin.Configuration; using Magicodes.Storage.AliyunOss.Core; using Magicodes.Storage.Core; using Magicodes.Storage.Local.Core; +using Magicodes.Storage.Tencent.Core; using Microsoft.AspNetCore.Hosting; using System; using System.IO; @@ -73,8 +74,9 @@ namespace Magicodes.Unity.Storage if (Convert.ToBoolean(_settingManager.GetSettingValueAsync(AppSettings.AliStorageManagement.IsEnabled).Result)) { - aliyunOssConfig = new AliyunOssConfig() { - AccessKeyId = _settingManager.GetSettingValueAsync(AppSettings.AliStorageManagement.AccessKeyId).Result, + aliyunOssConfig = new AliyunOssConfig() + { + AccessKeyId = _settingManager.GetSettingValueAsync(AppSettings.AliStorageManagement.AccessKeyId).Result, AccessKeySecret = _settingManager.GetSettingValueAsync(AppSettings.AliStorageManagement.AccessKeySecret).Result, Endpoint = _settingManager.GetSettingValueAsync(AppSettings.AliStorageManagement.EndPoint).Result }; @@ -105,7 +107,56 @@ namespace Magicodes.Unity.Storage StorageProvider = new AliyunOssStorageProvider(aliyunOssConfig); break; } - //TODO:腾讯云支持 + case "TencentCosStorageProvider": + { + TencentCosConfig tencentCosConfig; + + if (Convert.ToBoolean(_settingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.IsEnabled).Result)) + { + tencentCosConfig = new TencentCosConfig() + { + AppId = _settingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.AppId).Result, + BucketName = _settingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.BucketName).Result, + Region = _settingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.Region).Result, + SecretId = _settingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.SecretId).Result, + SecretKey = _settingManager.GetSettingValueAsync(AppSettings.TencentStorageManagement.SecretKey).Result + }; + } + else + { + tencentCosConfig = new TencentCosConfig() + { + AppId = _appConfiguration.Configuration["StorageProvider:TencentCosStorageProvider:AppId"], + BucketName = _appConfiguration.Configuration["StorageProvider:TencentCosStorageProvider:BucketName"], + Region = _appConfiguration.Configuration["StorageProvider:TencentCosStorageProvider:Region"], + SecretId = _appConfiguration.Configuration["StorageProvider:TencentCosStorageProvider:SecretId"], + SecretKey = _appConfiguration.Configuration["StorageProvider:TencentCosStorageProvider:SecretKey"] + }; + } + + if (tencentCosConfig.AppId.IsNullOrWhiteSpace()) + { + throw new UserFriendlyException("TencentCosStorageProvider AppId is null!"); + } + if (tencentCosConfig.BucketName.IsNullOrWhiteSpace()) + { + throw new UserFriendlyException("TencentCosStorageProvider BucketName is null!"); + } + if (tencentCosConfig.Region.IsNullOrWhiteSpace()) + { + throw new UserFriendlyException("TencentCosStorageProvider Region is null!"); + } + if (tencentCosConfig.SecretId.IsNullOrWhiteSpace()) + { + throw new UserFriendlyException("TencentCosStorageProvider SecretId is null!"); + } + if (tencentCosConfig.SecretKey.IsNullOrWhiteSpace()) + { + throw new UserFriendlyException("TencentCosStorageProvider SecretKey is null!"); + } + StorageProvider = new TencentStorageProvider(tencentCosConfig); + break; + } default: break; }