OSS SDK for iOS provides a convenient synchronous API to check whether a specific object exists in a bucket.
Usage notes
Before you run the sample code in this topic, you must create an OSSClient instance by using methods such as using a custom domain name or Security Token Service (STS). For more information, see Initialization.
NoteThe region of the bucket is determined by the endpoint specified for initialization.
Sample code
The following code provides an example on how to determine whether an object exists:
NSError * error = nil;
BOOL isExist = [client doesObjectExistInBucket:@"examplebucket" objectKey:@"file" error:&error];
if (!error) {
if(isExist) {
NSLog(@"File exists.");
} else {
NSLog(@"File not exists.");
}
} else {
NSLog(@"Error!");
}