全部产品
Search
文档中心

对象存储 OSS:iOS判断文件是否存在

更新时间:Dec 20, 2023

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!");
}