从Dropbox加载文件

时间:2013-02-21 02:06:40

标签: iphone ios xcode dropbox dropbox-api

我一直关注iOS平台的Dropbox tutorial。我在load文件中遇到了这行代码。

[[self restClient] loadFile:dropboxPath intoPath:localPath]

在这一行下面,它有一个描述上面代码的描述框,其中说明了:

Here, srcPath is the path in the user's Dropbox (you probably got this from a metadata object), and destPath is the location on the local device you want the file to be put after it has been downloaded. To find out when the file download either succeeds or fails implement the following DBRestClientDelegate methods:

1)首先,没有srcPath也没有destPath。因此,代码或代码描述都已过时/不正确。

2)其次,dropboxPath是什么?我假设它是我想从dropbox加载的文件。如果是这样,我如何指定我想要的文件?

3)如果我从dropbox加载.sqlite文件,我究竟要将该文件加载到哪里?

任何帮助都将非常感谢!

2 个答案:

答案 0 :(得分:2)

1)DropboxPath是您的文件存储在相应Dropbox帐户中的在线路径。

2)源路径将是DropboxPath,目标路径将是您移动设备上的路径,即文档目录。所有文件都应下载到文档目录或文档目录的其他目录中。

3)您的.sqlite文件只应加载到文档目录中。但项目代码应使用其NSPath来使用此文件。

有一个快乐的编码。!!享受。!!

答案 1 :(得分:1)

dropboxPath将指示文件中应用程序的Dropbox目录中的。例如,如果您的应用程序名为APP01,则用户的Dropbox登录名将具有APP01目录。要从中获取文件,您可以将其指定为@“/ theFile.txt”,Dropbox API应从用户的帐户获取APP01 / theFile.txt。在创建开发ID以连接到用户帐户时,Dropbox将对您的用户帐户进行沙盒访问。

localPath应该在你的应用程序的沙箱中,你可以使用

这样的沙箱
+ (NSString*) GetDocumentDirectory
{
    NSArray *paths =
    NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    return ((paths != nil) && ([paths count] > 0)) ? [paths objectAtIndex:0] : nil;
}

您可以将本地文件名附加到GetDocumentDirectory返回的内容。