You need to enable JavaScript to run this app.
文档中心
对象存储

对象存储

复制全文
下载 pdf
存储桶接口
创建桶(iOS SDK)
复制全文
下载 pdf
创建桶(iOS SDK)
桶(Bucket)是TOS的全局唯一的命名空间,相当于数据的容器,用来储存对象(Object)数据。新创建的桶名在 TOS 中必须是唯一的。​
示例代码​
如下代码展示如何创建一个新桶。​
​
// 从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];​
​
TOSCreateBucketInput *create = [TOSCreateBucketInput new];​
create.tosBucket = @"bucket-name";​
create.tosACL = TOSACLPublicRead;​
TOSTask *task = [client createBucket:create];​
[task continueWithBlock:^id _Nullable(TOSTask * _Nonnull task) {​
if (!task.error) {​
NSLog(@"Create bucket success.");​
TOSCreateBucketOutput *output = task.result;​
} else {​
NSLog(@"Create bucket failed, error: %@.", task.error);​
}​
return nil;​
}];​
​
​
最近更新时间:2025.08.27 11:43:59
这个页面对您有帮助吗?
有用
有用
无用
无用