OSS iOS SDK提供了方便的同步接口以检测Bucket中是否存在指定的文件。
示例代码
以下代码用于判断指定文件是否存在。
NSError * error = nil;
BOOL isExist = [client doesObjectExistInBucket:TEST_BUCKET withObjectKey:@"file1m" withError:&error];
if (!error) {
if(isExist) {
NSLog(@"File exists.");
} else {
NSLog(@"File not exists.");
}
} else {
NSLog(@"Error!");
}