static async Task EnableReplicationAsync() { try { ReplicationConfiguration replConfig = new ReplicationConfiguration { Role = roleArn, Rules = { new ReplicationRule { Prefix = "Tax", Status = ReplicationRuleStatus.Enabled, Destination = new ReplicationDestination { BucketArn = destinationBucketArn } } } }; PutBucketReplicationRequest putRequest = new PutBucketReplicationRequest { BucketName = sourceBucket, Configuration = replConfig }; PutBucketReplicationResponse putResponse = await s3Client.PutBucketReplicationAsync(putRequest); // Verify configuration by retrieving it. await RetrieveReplicationConfigurationAsync(s3Client); } catch (AmazonS3Exception e) { Console.WriteLine("Error encountered on server. Message:'{0}' when writing an object", e.Message); } catch (Exception e) { Console.WriteLine("Unknown encountered on server. Message:'{0}' when writing an object", e.Message); } }
/// <summary> /// This method adds replication rules to the S3 source bucket. /// </summary> /// <param name="client">The initialized S3 client object used to /// create and add the replication configuration to the source bucket.</param> /// <param name="sourceBucket">A string representing the name of the /// source S3 bucket.</param> /// <param name="destinationBucketArn">The ARN of the destination /// S3 bucket.</param> /// <param name="roleArn">The ARN of the role which will be used to /// replicate the contents of the source S3 bucket.</param> public static async Task EnableReplicationAsync(IAmazonS3 client, string sourceBucket, string destinationBucketArn, string roleArn) { try { ReplicationConfiguration replConfig = new () { Role = roleArn, Rules = { new ReplicationRule { Filter = new ReplicationRuleFilter{ Prefix = "Tax" }, Status = ReplicationRuleStatus.Enabled, Destination = new ReplicationDestination { BucketArn = destinationBucketArn, }, }, }, }; PutBucketReplicationRequest putRequest = new () { BucketName = sourceBucket, Configuration = replConfig, }; PutBucketReplicationResponse putResponse = await client.PutBucketReplicationAsync(putRequest); } catch (AmazonS3Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { PutBucketReplicationResponse response = new PutBucketReplicationResponse(); return(response); }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { PutBucketReplicationResponse response = new PutBucketReplicationResponse(); return response; }