本文介绍删除桶的示例代码。
如下代码展示如何删除空桶。
// 从STS服务获取的临时访问密钥和安全令牌(AccessKey、SecretKey、SecurityToken) TOSCredential *credential = [[TOSCredential alloc] initWithAccessKey:@"accesskey" secretKey:@"secretkey" securityToken:@"securityToken"]; TOSEndpoint *tosEndpoint = [[TOSEndpoint alloc] initWithURLString:@"endpoint" withRegion:@"region"]; TOSClientConfiguration *config = [[TOSClientConfiguration alloc] initWithEndpoint:tosEndpoint credential:credential]; TOSClient *client = [[TOSClient alloc] initWithConfiguration:config]; TOSDeleteBucketInput *delete = [TOSDeleteBucketInput new]; delete.tosBucket = @"bucket-name"; task = [client deleteBucket:delete]; [task continueWithBlock:^id(TOSTask *task) { if (!task.error) { NSLog(@"Delete bucket success."); TOSDeleteBucketOutput *output = task.result; } else { NSLog(@"Delete bucket failed, error: %@" ,task.error); } return nil; }];