namespace MiaoYu.Api.Admin.Models.Configs;
///
/// 程序配置信息映射类 appsettings.json
///
public class AppConfiguration : ISingletonSelfDependency
{
///
/// IConfiguration 通过属性注入
///
[Autowired]
public virtual IConfiguration _configuration { get; }
///
/// 程序配置信息映射类
///
public AppConfiguration()
{
}
///
/// 程序配置信息映射类
///
///
public AppConfiguration(IConfiguration configuration)
{
_configuration = configuration;
}
}
public class FileManagerNode
{
///
/// 上传文件大小限制
///
///
public string? MaxRequestBodySize { get; set; }
///
/// 服务器地址
///
///
public string? ServerUrl { get; set; }
///
/// 保存文件根路径
///
///
public string? DirectoryUrl { get; set; }
///
/// 上传文件大小
///
///
public string? MaxFileSizeLimit { get; set; }
///
/// 允许上传格式
///
///
public string? AllowExtensions { get; set; }
private long maxRequestBodySize = -1;
private long maxFileSizeLimit = -1;
///
/// 获取最大请求内容体长度
///
///
public long GetMaxRequestBodySize()
{
if (maxRequestBodySize == -1)
{
try
{
var value = MaxRequestBodySize.ToStorageByteLength();
maxRequestBodySize = value;
}
catch (Exception)
{
throw new Exception("MaxRequestBodySize 格式错误");
}
}
return maxRequestBodySize;
}
///
/// 获取最大文件长度
///
///
public long GetMaxFileSizeLimit()
{
if (maxFileSizeLimit == -1)
{
try
{
var value = MaxFileSizeLimit.ToStorageByteLength();
maxFileSizeLimit = value;
}
catch (Exception)
{
throw new Exception("MaxFileSizeLimit 格式错误");
}
}
return maxFileSizeLimit;
}
}