验证桶是否存在

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

接口定义:

- (void)headBucket:(AWSS3HeadBucketRequest *)request
     completionHandler:(void (^)(NSError *error))completionHandler

参数:

参数名 类型 说明
bucket NSString bucket名

代码示例:

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