public void Close() { if (_client != null) { _client.Dispose(); _client = null; } }
public void Open() { if( string.IsNullOrEmpty(accessKey) || string.IsNullOrEmpty(secretKey) ) throw new ArgumentException("AmazonS3 service requires an AWSAccessKey and AWSSecretKey in app.config"); // in the previous version, s3.amazonaws.com was used. This has the same serviceurl. /mh // http://docs.aws.amazon.com/general/latest/gr/rande.html Amazon.RegionEndpoint endpoint = Amazon.RegionEndpoint.USEast1; _client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey, endpoint); }
private async Task Upload(string objectKey, MemoryStream stream, Amazon.S3.IAmazonS3 client) { var request = new Amazon.S3.Model.PutObjectRequest() { BucketName = _config.BucketName, Key = objectKey, InputStream = stream, ServerSideEncryptionMethod = Amazon.S3.ServerSideEncryptionMethod.AES256 }; var response = await client.PutObjectAsync(request); }
private async Task <Stream> Download(string objectKey, Amazon.S3.IAmazonS3 s3Client) { var request = new Amazon.S3.Model.GetObjectRequest() { BucketName = _config.BucketName, Key = objectKey }; var response = await s3Client.GetObjectAsync(request); return(response.ResponseStream); }
public void Open() { if (string.IsNullOrEmpty(accessKey) || string.IsNullOrEmpty(secretKey)) { throw new ArgumentException("AmazonS3 service requires an AWSAccessKey and AWSSecretKey in app.config"); } // in the previous version, s3.amazonaws.com was used. This has the same serviceurl. /mh // http://docs.aws.amazon.com/general/latest/gr/rande.html Amazon.RegionEndpoint endpoint = Amazon.RegionEndpoint.USEast1; _client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey, endpoint); }
public async Task CreateBucket_Success() { // Arrange const string bucketName = "new-bucket"; Amazon.S3.IAmazonS3 client = _s3Resource.GetCLient(); var putBucketRequest = new PutBucketRequest { BucketName = bucketName, }; // Act await client.PutBucketAsync(putBucketRequest, default); ListBucketsResponse result = await client.ListBucketsAsync(default);
public AmazonContainer(string bucketName, string directoryName, Amazon.S3.IAmazonS3 amazonS3, IAmazonContentFactory amazonContentFactory, IContentNameProvider contentNameProvider, IContentIdentifierGenerator contentIdentifierGenerator, IContentHashValidator contentHashValidator) { _bucketName = bucketName; _directoryName = directoryName; _amazonS3 = amazonS3; _amazonContentFactory = amazonContentFactory; _contentNameProvider = contentNameProvider; _contentIdentifierGenerator = contentIdentifierGenerator; _contentHashValidator = contentHashValidator; }
public static void Configure(System.String AccessKeyID, System.String SecretAccessKey, Amazon.RegionEndpoint RegionEndpoint) { if (System.String.IsNullOrWhiteSpace(AccessKeyID)) { throw new System.Exception("The AccessKeyID cannot be null or empty."); } if (System.String.IsNullOrWhiteSpace(SecretAccessKey)) { throw new System.Exception("The SecretAccessKey cannot be null or empty."); } if (RegionEndpoint == null) { throw new System.Exception("The RegionEndpoint cannot be null."); } SoftmakeAll.SDK.CloudStorage.AWS.Environment._S3Client = new Amazon.S3.AmazonS3Client(AccessKeyID, SecretAccessKey, RegionEndpoint); }