protected Uploader_S3(Config_S3 settings) { AmazonS3Config config = new AmazonS3Config(); config.ServiceURL = settings.Provider; config.ForcePathStyle = settings.ForcePathStyle; if (settings.Proxy != null) { logger.Info($"Используем прокси: {settings.Proxy.Host}:{settings.Proxy.Port}"); config.ProxyHost = settings.Proxy.Host; config.ProxyPort = settings.Proxy.Port; if (settings.Proxy.Login != null && settings.Proxy.Password != null) { config.ProxyCredentials = new NetworkCredential(settings.Proxy.Login, settings.Proxy.Password); var maskedPass = new string('#', settings.Proxy.Password.Length); logger.Info($"С логином {settings.Proxy.Login} и паролем {maskedPass}"); } } client = new AmazonS3Client(settings.Login, settings.Password, config); transferUtility = new TransferUtility(client); ListBucketsResponse response = client.ListBuckets(); bucket = response.Buckets.First(x => x.BucketName == settings.Container); if (bucket == null) { throw new InvalidOperationException($"Can't find S3 bucket: {settings.Container}"); } logger.Info($"Подключены к S3 хранилищу от имени '{settings.Login}' к контейнеру '{settings.Container}'"); }
public static Uploader_S3 GetInstance(Config_S3 settings) { lock (padlock) { return(_instance ?? (_instance = new Uploader_S3(settings))); } }