本文介绍删除对象的示例代码。
如下代码展示如何删除对象。
// 从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]; TOSDeleteObjectInput *input = [TOSDeleteObjectInput new]; input.tosBucket = @"bucket-name"; input.tosKey = @"object-name"; TOSTask *task = [_client deleteObject:input]; [task continueWithBlock:^id(TOSTask *task) { if (!task.error) { NSLog(@"Delete object success."); } else { NSLog(@"Delete object failed, error: %@" ,task.error); } return nil; }];