更新时间:2022-09-13 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(totalBytesWritten*10000/totalBytesExpectedToWrite)/100);
};
[client getObject:request completionHandler:^(OBSGetObjectResponse *response, NSError *error){
NSLog(@"%@",response.etag);
}]; 
- 调用getObject返回一个OBSObject实例,该实例包含对象内容及其属性。
- 更多下载对象的信息,请参见下载对象。
父主题:快速入门

