Bloom.WebLibraryIntegration.BloomS3Client.GetAmazonS3 C# (CSharp) Method

GetAmazonS3() private method

private GetAmazonS3 ( string bucketName ) : IAmazonS3
bucketName string
return IAmazonS3
        private IAmazonS3 GetAmazonS3(string bucketName)
        {
            //Note, it would probably be fine to just generate this each time,
            //but this was the more conservative approach when refactoring
            //to allow a single client to access arbitrary buckets, thus requiring
            //appropriate change of access keys, thus requiring changing AmazonS3Client objects.
            if(bucketName != _previousBucketName)
            {
                var accessKeys = AccessKeys.GetAccessKeys(bucketName);
                if (_amazonS3 != null)
                    _amazonS3.Dispose();
                _amazonS3 = new AmazonS3Client(accessKeys.S3AccessKey,
                    accessKeys.S3SecretAccessKey, _s3Config);

                _previousBucketName = bucketName;
            }
            return _amazonS3; // we keep this so that we can dispose of it later.
        }