删除桶

Bucket是用于存储对象(Object)的容器,所有的对象都必须隶属于某个Bucket。本文介绍如何删除桶(Bucket)。

注意:待删除的bucket必须是空的,否则会报错。

接口:

- (void)deleteBucket:(AWSS3DeleteBucketRequest *)request
     completionHandler:(void (^)(NSError *error))completionHandler

参数:

参数名 类型 说明
bucket NSString 要删除的bucket名

代码示例:

- (void) deleteBucketWithName:(NSString*) bucketName {
    AWSS3DeleteBucketRequest *request = [[AWSS3DeleteBucketRequest alloc] init];
    request.bucket = bucketName;
    [self.s3 deleteBucket:request completionHandler:^(NSError * _Nullable error) {
        if (error != nil) {
            NSLog(@"error: %@", error);
            return;
        }
    }];
}