/// <summary> /// 添加OSS功能 /// </summary> /// <param name="services"></param> /// <param name="cfg"></param> /// <returns></returns> public static IServiceCollection AddOSS(this IServiceCollection services, IConfiguration cfg) { var config = new OSSConfig(); var section = cfg.GetSection("OSS"); if (section != null) { section.Bind(config); } services.AddSingleton(config); var assembly = AssemblyHelper.LoadByNameEndString($".Lib.OSS.{config.Provider.ToString()}"); Check.NotNull(assembly, $"OSS实现程序集({config.Provider.ToString()})未找到,请安装 NetModular.Lib.OSS.{config.Provider.ToString()} 包"); var providerType = assembly.GetTypes().FirstOrDefault(m => typeof(IFileStorageProvider).IsAssignableFrom(m)); if (providerType != null) { services.AddSingleton(typeof(IFileStorageProvider), providerType); } return(services); }
public MinioHelper(OSSConfig config) { _client = new MinioClient(config.Minio.Endpoint, config.Minio.AccessKey, config.Minio.SecretKey ); }
/// <summary> /// 添加OSS功能 /// </summary> /// <param name="services"></param> /// <param name="cfg"></param> /// <returns></returns> public static IServiceCollection AddOSS(this IServiceCollection services, IConfiguration cfg) { var config = new OSSConfig(); // 从appsetting.json中读取 var section = cfg.GetSection("OSS"); if (section != null) { // 配置数据绑定实体类 section.Bind(config); } // 如果未启用oss服务 if (!config.IsEnabled) { return(services); } if (config.Aliyun != null && config.Aliyun.Domain.NotNull() && !config.Aliyun.Domain.EndsWith("/")) { config.Aliyun.Domain += "/"; } services.AddSingleton(config); var assembly = AssemblyHelper.LoadByNameEndString($"OSS.{config.Provider}"); if (assembly == null) { return(services); } var providerType = assembly.GetTypes().FirstOrDefault(m => typeof(IFileStorageProvider).IsAssignableFrom(m)); if (providerType != null) { services.AddSingleton(typeof(IFileStorageProvider), providerType); } return(services); }
public AliyunFileStorageProvider(AliyunHelper helper, OSSConfig config) { _helper = helper; _config = config.Aliyun; }
public AliyunHelper(OSSConfig config, ILogger <AliyunHelper> logger) { _logger = logger; _config = config.Aliyun; }
public MinioHelper(OSSConfig config, ILogger <MinioHelper> logger) { _logger = logger; _config = config.Minio; }
public MinioFileStorageProvider(MinioHelper helper, OSSConfig config) { _helper = helper; _minoConfig = config.Minio; }
public QiniuTokenManager(OSSConfig config) { _config = config.Qiniu; RefreshTimer(); }
public QiniuFileStorageProvider(QiniuHelper helper, OSSConfig config) { _helper = helper; _config = config.Qiniu; }
public QiniuHelper(QiniuTokenManager tokenManager, ILogger <QiniuHelper> logger, OSSConfig config) { _tokenManager = tokenManager; _logger = logger; _config = config.Qiniu; }