更新时间:2026-08-28 GMT+08:00
下载对象
以下代码展示如何获取对象的内容:
NSString * outfilePath = [NSTemporaryDirectory() stringByAppendingString:@"filename"];
OBSGetObjectToFileRequest *request = [[OBSGetObjectToFileRequest alloc]initWithBucketName:@"bucketname" objectKey:@"objectname" downloadFilePath:outfilePath];
// 下载进度
request.downloadProgressBlock = ^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
NSLog(@"%0.1f%%",(float)floor((totalBytesExpectedToWrite > 0) ? (totalBytesWritten*10000/totalBytesExpectedToWrite) : 0)/100);
};
[client getObject:request completionHandler:^(OBSGetObjectResponse *response, NSError *error){
if(response.etag){NSLog(@"%@",response.etag);}
}]; 父主题: 快速入门
