private static IAmazonS3 CreateS3Client( ICredentialsProvider credentialsProvider, IS3Options <T> options ) { AWSCredentials credentials = credentialsProvider.GetCredentials(options.CredentialsProfile); if (!string.IsNullOrWhiteSpace(options.Role)) { credentials = credentialsProvider.AssumeRole( credentials, options.Role ); } if (!string.IsNullOrWhiteSpace(options.RegionEndpoint)) { AmazonS3Config config = new AmazonS3Config() { RegionEndpoint = RegionEndpoint.GetBySystemName(options.RegionEndpoint) }; return(new AmazonS3Client(credentials, config)); } return(new AmazonS3Client(credentials)); }
public S3Context( ICredentialsProvider credentialsProvider, IS3Options <T> options ) { if (options is null) { throw new ArgumentException($"{nameof( options )} must not be null.", nameof(options)); } if (credentialsProvider is null) { throw new ArgumentException($"{nameof( credentialsProvider )} must not be null.", nameof(credentialsProvider)); } Client = CreateS3Client(credentialsProvider, options); }