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

对象存储

复制全文
下载 pdf
上传对象
追加上传(iOS SDK)
复制全文
下载 pdf
追加上传(iOS SDK)

此接口用于追加写对象,通过 AppendObject 接口创建的对象类型为 Appendable Object,通过 PutObject 上传的对象类型为 Normal Object。

示例代码

如下代码展示如何追加写对象到目标桶中。

// 从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];

TOSAppendObjectInput *append = [TOSAppendObjectInput new];
append.tosBucket = @"bucket-name";
append.tosKey = @"object-name";
append.tosOffset = 0;
append.tosContent = your_data; // NSData
TOSTask *task = [client putObjectFromFile:append];
[task continueWithBlock:^id(TOSTask *task) {
    if (!task.error) {
        NSLog(@"Append object success.");
        TOSPutObjectFromFileOutput *output = task.result;
    } else {
        NSLog(@"Append object failed, error: %@" ,task.error);
    }
    return nil;
}];
最近更新时间:2024.02.04 18:30:59
这个页面对您有帮助吗?
有用
有用
无用
无用