From ad4d5ec84adf8f379f0bb377cfb9b1221029e2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8D=E6=BD=9C?= Date: Tue, 18 Dec 2018 11:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=85=BE=E8=AE=AF=E4=BA=91?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Storage/Dto/AliStorageSettingEditDto.cs | 3 - .../Storage/Dto/StorageSettingEditDto.cs | 5 ++ .../Dto/TencentStorageSettingEditDto.cs | 39 ++++++++++ .../Storage/StorageSettingAppService.cs | 26 ++++++- .../Localization/Admin/Admin-zh-CN.xml | 8 +++ src/admin/ui/package-lock.json | 28 ++++++-- .../settings/storage-settings.component.html | 30 ++++++++ .../settings/storage-settings.component.ts | 7 +- .../layout/nav/app-navigation.service.ts | 1 + .../shared/service-proxies/service-proxies.ts | 72 +++++++++++++++++-- .../Configuration/AppSettingProvider.cs | 11 ++- .../Configuration/AppSettings.cs | 18 +++++ .../Magicodes.Unity/Magicodes.Unity.csproj | 1 + .../Magicodes.Unity/Storage/StorageManager.cs | 57 ++++++++++++++- 14 files changed, 283 insertions(+), 23 deletions(-) create mode 100644 src/admin/api/Admin.Application/Configuration/Storage/Dto/TencentStorageSettingEditDto.cs 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 0f18ed1d..e9e51d98 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 f7ee1057..c9e1f55f 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 00000000..ca000a83 --- /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 3444939a..15851188 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 75c943d7..af748c97 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 4923c739..ea8f078c 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 90340f42..df9b7192 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 5b6f13a6..8f24043e 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 4ff6a1fc..dcf541e8 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 137a9b0c..2869dc9a 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 358448c7..4c50b405 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 180f1a6b..f38d15c0 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 cfc4c3f9..988f3d33 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 0cced523..3dc35f22 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; } -- Gitee