创建桶
Bucket是用于存储对象(Object)的容器,所有的对象都必须隶属于某个Bucket。本文介绍如何创建桶(Bucket)。
接口定义:
- (void)listBuckets:(AWSRequest *)request
completionHandler:(void (^)(AWSS3ListBucketsOutput *response, NSError *error))completionHandler
参数:
参数名 | 类型 | 说明 |
---|---|---|
bucket | NSString | bucket名称 |
createBucketConfiguration | AWSS3CreateBucketConfiguration | 如果非NULL,则是用于授权签名的AWS区域 |
ACL | AWSS3BucketCannedACL | 设定的权限 |
代码示例:
- (void) createBucketWithName:(NSString*) bucketName {
AWSS3CreateBucketRequest *request = [[AWSS3CreateBucketRequest alloc] init];
request.bucket = bucketName;
[self.s3 createBucket:request completionHandler:^(AWSS3CreateBucketOutput * _Nullable response, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"error: %@", error);
return;
}
}];
}