static void DeleteBucketLogging() { try { SetBucketLoggingRequest request = new SetBucketLoggingRequest(); request.BucketName = bucketName; request.Configuration = new LoggingConfiguration(); SetBucketLoggingResponse response = client.SetBucketLogging(request); Console.WriteLine("Delete bucket logging response: {0}", response.StatusCode); } catch (ObsException ex) { Console.WriteLine("Exception errorcode: {0}, when delete bucket logging.", ex.ErrorCode); Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage); } }
static void SetBucketLogging() { try { AccessControlList acl = new AccessControlList(); acl.Owner = new Owner(); acl.Owner.Id = "domainId"; Grant item = new Grant(); item.Permission = PermissionEnum.FullControl; GroupGrantee group = new GroupGrantee(); group.GroupGranteeType = GroupGranteeEnum.LogDelivery; item.Grantee = group; acl.Grants.Add(item); SetBucketAclRequest setAclRequest = new SetBucketAclRequest { BucketName = "targetbucketname", AccessControlList = acl, }; SetBucketAclResponse setAclResponse = client.SetBucketAcl(setAclRequest); Console.WriteLine("Set bucket target acl response: {0}", setAclResponse.StatusCode); LoggingConfiguration loggingConfig = new LoggingConfiguration(); loggingConfig.TargetBucketName = "targetbucketname"; loggingConfig.TargetPrefix = "targetPrefix"; SetBucketLoggingRequest request = new SetBucketLoggingRequest() { BucketName = bucketName, Configuration = loggingConfig }; SetBucketLoggingResponse response = client.SetBucketLogging(request); Console.WriteLine("Set bucket logging status: {0}", response.StatusCode); } catch (ObsException ex) { Console.WriteLine("Exception errorcode: {0}, when set bucket logging.", ex.ErrorCode); Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage); } }