Accessing Camera Volumes

Each volume (SD, compact flash card etc.) mounted on a camera is represented by an instance of the EOSVolume class. The easiest way to retrieve volumes is as follows:
//camera is an instance of EOSCamera with an open session

//get list of volumes
NSArray* volumeList = [camera volumes];

//loop though each volume
for (EOSVolume* volume in volumeList){

    //get volume info
    EOSVolumeInfo* info = [volume getInfo:nil];

    //print volume name
    NSLog(@"Found volume: %@", [info name]);


The EOSVolumeInfo class contains several properties such as the volume's name, capacity etc.

Accessing Files

Each file (including directories) stored on a volume is represented by an instance of the EOSFile class. The easiest way to retrieve files from a volume is as follows:
//get files in the root directory
NSArray* files = [volume files];

//loop though each file
for (EOSFile* file in files){

    //get file info
    EOSFileInfo* info = [file info:nil];

    //check whether file is a directory
    if ([info isDirectory]){

        //print directory name
        NSLog(@"Found directory: %@", [info name]);


        //print file name
        NSLog(@"Found file: %@", [info name]);



The same method of retrieving files can be applied to an EOSFile directory. The EOSFileInfo class contains properties such as the file's name, size etc.

Downloading a File

Files (that are not directories) can be downloaded to the local filesystem. This can be achieved by using EOSFile's downloadWithOptions:delegate:contextInfo: method.

The options parameter should be a dictionary, that may contain the keys: EOSDownloadDirectoryURL, EOSSaveAsFilename and EOSOverwrite. The default values for these keys are: the root directory, the current name of the file and NO respectively.

The delegate parameter should be an object that conforms to EOSDownloadProtocol. This implements a method that is called once the download is complete.

The following example shows an implementation of a method that downloads a file and prints its location when finished.
- (void)downloadFile:(EOSFile*)file{
    NSURL* downloadDirectory = [NSURL URLWithString:@"/Users/Bob/Pictures/"];
    NSDictionary* options = [NSDictionary dictionaryWithObject:downloadDirectory forKey:EOSDownloadDirectoryURL];
    [file downloadWithOptions:options delegate:self contextInfo:nil];

//EOSDownloadProtocol method
- (void)didDownloadFile:(EOSFile*)file withOptions:(NSDictionary*)options contextInfo:(id)contextInfo error:(NSError*)error{

    if (error){

        NSLog(@"Failed to download file");


        NSURL* downloadDirectory = [options objectForKey:EOSDownloadDirectoryURL];
        //the options now contain the key EOSSavedFilename
        NSString* fileName = [options objectForKey:EOSSavedFilename];
        //generate full URL
        NSURL* fullURL = [NSURL URLWithString:fileName relativeToURL:downloadDirectory];

        NSLog(@"Downloaded file: %@", fullURL);