2013-02-21 56 views
1

我一直在關注iOS平臺的保存箱tutorial。我碰到這行代碼load一個文件。從Dropbox中加載文件

[[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

1)DropboxPath是您的文件存儲在相應的Dropbox帳戶中的在線路徑。

2)源路徑爲DropboxPath,目標路徑爲移動路徑,即文檔目錄。所有文件應該下載到文檔目錄或文檔目錄的其他目錄中。

3)你的.sqlite文件應該只加載到文檔目錄中。但是項目代碼應該使用它的NSPath來使用這個文件。

有一個快樂的編碼。請享用。!!

+0

錯誤我給桌面上的本地路徑,當我從Dropbox下載數據時,我的所有數據從桌面上刪除..我能做些什麼,從桌面恢復我的所有數據。 – 2016-09-16 07:12:27

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回到真實。