繁体   English   中英

使用iPhone SDK将文件夹上传到DropBox

[英]Upload a folder to DropBox using iPhone SDK

我是iOS开发的初学者,刚开始使用DropBox SDK开发应用程序。

我当前正在使用XCode 3.2.5,并使用模拟器版本4.2。 我想知道是否有任何方法可以使用iPhone的DropBox SDK将包含n个文件的整个文件夹(目录)的内容直接上传到我们的App帐户。

我在网络上的各个论坛上进行了讨论,但是找不到解决此问题的答案。 是否有可能解决此问题的方法。 如果是,我们如何实施? 你能帮忙吗?

编辑:我已经在iOS的DropBox SDK版本1.1中查找了API,但是,它没有任何递归上载目录或其所有内容的功能。 因此,我是否必须递归遍历目录的内容并发送多个请求? 请帮忙。

实现此目的的最简单方法是这样的:

NSFileManager *fmgr = [NSFileManager defaultManager];
NSString *localDirectoryPath = @"path/to/directory";
NSArray *subPaths = [fmgr subpathsOfDirectoryAtPath:localDirectory error:&error];


for(NSString *path in subPaths){
        BOOL isDir;
        NSString *localPath = [userDir URLByAppendingPathComponent:path].path;
        [fmgr fileExistsAtPath:localPath isDirectory:&isDir];
        if(!isDir){
            NSString *filename = [path lastPathComponent];

            NSString *destPath = [[[@"/" stringByAppendingPathComponent:@"base/path"]
stringByAppendingPathComponent:path.stringByDeletingLastPathComponent]
                                  stringByAppendingString:@"/"];

            [[self restClient] uploadFile:filename toPath:destPath withParentRev:nil fromPath:localPath];
        }
    }

单击此处: https : //github.com/chrishulbert/CHBgDropboxSync

用于上传和下载Dropbox文件夹/ Direcotry。

阅读并使用以下链接中的内容

http://www.nanaimostudio.com/blog/2011/1/20/how-to-synchronize-your-app-data-using-dropbox-api.html

绝对可以帮助您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM