Files
caliverse_server/ServerBase/S3/S3Config.cs
2025-05-01 07:20:41 +09:00

61 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using ServerCore;
namespace ServerBase;
public partial class S3Connector : S3ConnectorBase, IModule, IInitializer
{
public class ConfigParam : IConfigParam
{
public string ServiceType { get; set; } = string.Empty;
public string AccessKey { get; set; } = string.Empty;
public string SecretKey { get; set; } = string.Empty;
public string Region { get; set; } = string.Empty;
public string ServiceFolderName { get; set; } = string.Empty;
public Result tryReadFromJsonOrDefault(JObject jObject)
{
var result = new Result();
var err_msg = string.Empty;
try
{
ServiceType = jObject["ServiceType"]?.Value<string>() ?? string.Empty;
var aws = jObject["AWS"];
NullReferenceCheckHelper.throwIfNull(aws, () => $"aws is null !!!");
AccessKey = aws["AccessKey"]?.Value<string>() ?? string.Empty;
SecretKey = aws["SecretKey"]?.Value<string>() ?? string.Empty;
Region = aws["Region"]?.Value<string>() ?? string.Empty;
ServiceFolderName = jObject["ServiceFolderName"]?.Value<string>() ?? string.Empty;
return result;
}
catch (Exception e)
{
var error_code = ServerErrorCode.TryCatchException;
err_msg = $"Exception !!!, Failed to perform in tryReadFromJsonOrDefault() !!! : errorCode:{error_code}, exception:{e} - {this.getTypeName()}";
result.setFail(error_code, err_msg);
Log.getLogger().error(err_msg);
return result;
}
}
public string toBasicString()
{
return $"ConfigParam: ServiceType:{ServiceType}, AccessKey:{AccessKey}, SecretKey:{SecretKey}, Region:{Region}, ServiceFolderName:{ServiceFolderName}";
}
};
}