Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor improvements - move Amazon settings to the new class (changes in App_Settings)

support0979135c2864
diff --git a/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs b/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
index 9991df1d2..b51c51f9d 100644
--- a/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
+++ b/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
@@ -21,7 +21,7 @@ namespace Grand.Business.Storage.Services
{
#region Fields
- private readonly AppConfig _config;
+ private readonly AmazonConfig _config;
private readonly string _bucketName;
private readonly string _distributionDomainName;
private bool _bucketExist = false;
@@ -39,7 +39,7 @@ namespace Grand.Business.Storage.Services
IMediaFileStore mediaFileStore,
MediaSettings mediaSettings,
StorageSettings storageSettings,
- AppConfig config)
+ AmazonConfig config)
: base(pictureRepository,
logger,
mediator,
diff --git a/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs b/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs
index 29b3d83b1..b7082f132 100644
--- a/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs
@@ -20,8 +20,12 @@ namespace Grand.Business.Storage.Startup
services.AddScoped<IDownloadService, DownloadService>();
//picture service
- var useAzureBlobStorage = !String.IsNullOrEmpty(config.AzureBlobStorageConnectionString);
- var useAmazonBlobStorage = (!String.IsNullOrEmpty(config.AmazonAwsAccessKeyId) && !String.IsNullOrEmpty(config.AmazonAwsSecretAccessKey) && !String.IsNullOrEmpty(config.AmazonBucketName) && !String.IsNullOrEmpty(config.AmazonRegion));
+ var useAzureBlobStorage = !string.IsNullOrEmpty(config.AzureBlobStorageConnectionString);
+
+ var amazonconfig = new AmazonConfig();
+ configuration.GetSection("Amazon").Bind(amazonconfig);
+
+ var useAmazonBlobStorage = (!string.IsNullOrEmpty(amazonconfig.AmazonAwsAccessKeyId) && !string.IsNullOrEmpty(amazonconfig.AmazonAwsSecretAccessKey) && !string.IsNullOrEmpty(amazonconfig.AmazonBucketName) && !string.IsNullOrEmpty(amazonconfig.AmazonRegion));
if (useAzureBlobStorage)
{
diff --git a/src/Core/Grand.Infrastructure/Configuration/AmazonConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AmazonConfig.cs
new file mode 100644
index 000000000..482e98d7d
--- /dev/null
+++ b/src/Core/Grand.Infrastructure/Configuration/AmazonConfig.cs
@@ -0,0 +1,31 @@
+namespace Grand.Infrastructure.Configuration
+{
+ public partial class AmazonConfig
+ {
+ /// <summary>
+ /// Amazon Access Key
+ /// </summary>
+ public string AmazonAwsAccessKeyId { get; set; }
+
+ /// <summary>
+ /// Amazon Secret Access Key
+ /// </summary>
+ public string AmazonAwsSecretAccessKey { get; set; }
+
+ /// <summary>
+ /// Amazon Bucket Name using for identifying resources
+ /// </summary>
+ public string AmazonBucketName { get; set; }
+
+ /// <summary>
+ /// Amazon Domain name for cloudfront distribution
+ /// </summary>
+ public string AmazonDistributionDomainName { get; set; }
+
+ /// <summary>
+ /// Amazon Region
+ /// http://docs.amazonwebservices.com/AmazonS3/latest/BucketConfiguration.html#LocationSelection
+ /// </summary>
+ public string AmazonRegion { get; set; }
+ }
+}
diff --git a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
index d84a61bd4..1eb75889e 100644
--- a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
@@ -45,10 +45,7 @@ namespace Grand.Infrastructure.Configuration
/// Gets or sets a value indicating whether copy dll plugin files to /Plugins/bin on application startup
/// </summary>
public bool PluginShadowCopy { get; set; }
-
-
-
/// <summary>
/// A value indicating whether the site is run on Windows Azure Web Apps
/// </summary>
@@ -68,32 +65,6 @@ namespace Grand.Infrastructure.Configuration
/// </summary>
public string AzureBlobStorageEndPoint { get; set; }
- /// <summary>
- /// Amazon Access Key
- /// </summary>
- public string AmazonAwsAccessKeyId { get; set; }
-
- /// <summary>
- /// Amazon Secret Access Key
- /// </summary>
- public string AmazonAwsSecretAccessKey { get; set; }
-
- /// <summary>
- /// Amazon Bucket Name using for identifying resources
- /// </summary>
- public string AmazonBucketName { get; set; }
-
- /// <summary>
- /// Amazon Domain name for cloudfront distribution
- /// </summary>
- public string AmazonDistributionDomainName { get; set; }
-
- /// <summary>
- /// Amazon Region
- /// http://docs.amazonwebservices.com/AmazonS3/latest/BucketConfiguration.html#LocationSelection
- /// </summary>
- public string AmazonRegion { get; set; }
-
/// <summary>
/// A list of plugins to be ignored during start application - pattern
/// </summary>
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs
index 19da37e09..18955de84 100644
--- a/src/Core/Grand.Infrastructure/StartupBase.cs
+++ b/src/Core/Grand.Infrastructure/StartupBase.cs
@@ -198,6 +198,7 @@ namespace Grand.Infrastructure
services.StartupConfig<ApiConfig>(configuration.GetSection("Api"));
services.StartupConfig<GrandWebApiConfig>(configuration.GetSection("GrandWebApi"));
services.StartupConfig<LiteDbConfig>(configuration.GetSection("LiteDb"));
+ services.StartupConfig<AmazonConfig>(configuration.GetSection("Amazon"));
//set base application path
var provider = services.BuildServiceProvider();
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index a9cda6ac3..6f3ef6474 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -63,15 +63,6 @@
"AzureBlobStorageContainerName": "",
"AzureBlobStorageEndPoint": "",
- //Amazon Blob storage
- //<!--Available Region System Names can be found here http://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region -->
- "AmazonAwsAccessKeyId": "",
- "AmazonAwsSecretAccessKey": "",
- "AmazonBucketName": "",
- "AmazonRegion": "",
- "AmazonDistributionDomainName": "", //Domain name for cloudfront distribution
-
-
//For developers - more info you can find at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/
//https://github.com/dotnet/roslyn/wiki/Roslyn-Overview
"UseRoslynScripts": false,
@@ -158,6 +149,17 @@
"UrlRewriteHttpsOptionsPort": 443,
"UrlRedirectToHttpsPermanent": false
},
+ "Amazon": {
+
+ //Amazon Blob storage
+ //<!--Available Region System Names can be found here http://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region -->
+ "AmazonAwsAccessKeyId": "",
+ "AmazonAwsSecretAccessKey": "",
+ "AmazonBucketName": "",
+ "AmazonRegion": "",
+ "AmazonDistributionDomainName": "" //Domain name for cloudfront distribution
+
+ },
"FacebookSettings": {
//Facebook-assigned App ID
"AppId": "",