You can call the HeadObject operation to obtain only the metadata but not the content of an object.

Note
  • Object metadata includes HTTP headers and user metadata. For more information, see Manage object metadata.
  • You cannot configure or modify object metadata by using the OSS SDK for iOS.

Examples

The following code provides an example on how to query object metadata:

OSSHeadObjectRequest * request = [OSSHeadObjectRequest new];
// Specify the name of the bucket. Example: examplebucket. 
request.bucketName = @"examplebucket";
// Specify the full path of the object. Do not include the bucket name in the full path. Example: exampledir/exampleobject.txt. 
request.objectKey = @"exampledir/exampleobject.txt";

OSSTask * headTask = [client headObject:request];

[headTask continueWithBlock:^id(OSSTask *task) {
    if (!task.error) {
        NSLog(@"head object success!");
        OSSHeadObjectResult * result = task.result;
        NSLog(@"header fields: %@", result.httpResponseHeaderFields);
        for (NSString * key in result.objectMeta) {
            NSLog(@"ObjectMeta: %@ - %@", key, [result.objectMeta objectForKey:key]);
        }
    } else {
        NSLog(@"head object failed, error: %@" ,task.error);
    }
    return nil;
}];

References

For more information about the API operation that you can call to query object metadata, see GetObjectMeta.