iOS DropboxSDK,获取远程子目录和内容

Wri*_*sCS 1 asynchronous objective-c dropbox ios

我有一个远程目录,在Dropbox上有几个子目录和文件.

偏远方面:

-Mobile Profiles *(root)*
-- Custom Profiles
--- Profile1
--- Profile2
--- Profile3
Run Code Online (Sandbox Code Playgroud)

使用文件上载文件和目录/子目录不是问题.在将子目录及其内容从dropbox下载到设备时,我有一个大脑放屁.

-(void)backupCustomProfiles {
    for ( NSString *file in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MP_CUSTOM error:&error] ) {
        [self.restClient uploadFile:file toPath:@"/Mobile Profiles/Custom Profiles/" fromPath:EasyStrings(MP_CUSTOM,file)];
    }
}
Run Code Online (Sandbox Code Playgroud)

得到

-(void)restoreCustomProfiles {
    for ( ) {
        /* ? */
    }
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何遍历远程端的子目录.

Lac*_*che 5

首先加载目录元数据,然后加载它引用的文件.

要限制并行提取的数量,请对所有loadMetadata和loadFile调用使用NSOperationQueue来限制并行提取的数量.为避免冗余文件下载,请记住plist中下载的元数据.

- (void) restoreCustomProfiles
{
    [self.client loadMetadata:@"/Mobile Profiles/Custom Profiles" withHash:hash];
}

- (void) restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata
{
    for (DBMetadata* child in metadata.contents) {
        NSString *path = [child.path lowercaseString];

        if (child.isDirectory) {
            [client loadMetadata:child.path withHash:hash];
        } else {
            [client loadFile:pathToDownload intoPath:[
                                self.directory stringByAppendingString:path]];
        }
    }
}

- (void) restClient:(DBRestClient*)client loadedFile:(NSString*)destPath
{
    // successfully downloaded a file to destPath
}
Run Code Online (Sandbox Code Playgroud)