2015-01-10 23 views
0

我嘗試從使用目標c的dropbox中刪除文件或文件夾,並使用目標c執行dropbox中的替換文件。 我在訪問這個鏈接https://www.dropbox.com/developers/core/docs,但我不能得到任何解決方案。我也用谷歌,但我找不到刪除文件夾,文件或替換文件的代碼。 你可以給一些解決方案。所以我可以走得更遠。如何從Dropbox中刪除文件或文件夾使用objectiv-c

這段代碼我試過但我無法得到解決方案。 你能檢查這個嗎?

-(void)DeleteFile 
{ 
    DBRestClient *dbClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]]; 
    [dbClient deletePath:DBdata.path];//DBdata object is DBMetadata for geting path from dropbox 
} 

-(void)uploadFileToDropBox:(NSString *)filePath 
{ 
    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentPath = [searchPaths objectAtIndex:0]; 
    NSString *path = [documentPath stringByAppendingPathComponent:@"/MortgageCalculator.sqlite"]; 


    [self.restClient uploadFile:@"MortgageCalculator.sqlite" toPath:filePath withParentRev:nil fromPath:path]; 
} 

請給演示刪除文件,文件夾和文件替換

感謝

解決方案 嘿, 我得到的解決方案。 請把這個委託方法

- (void)restClient:(DBRestClient*)client deletedPath:(NSString *)path 
{ 

} 
- (void)restClient:(DBRestClient*)client deletePathFailedWithError:(NSError*)error 
{ 

} 

,並把這個代碼的刪除方法

DBMetadata *metadata = [marrDownloadData objectAtIndex:indexforyourfile]; 
[self.restClient deletePath:metadata.path]; 
+0

https://www.dropbox.com/developers/core/docs#fileops-delete < - 這個文檔可以幫助你。請提供您的代碼片段和日誌以指出其失敗的位置。 –

+0

感謝您的重播 我在這裏編輯我的問題我添加我的code.this代碼我試了。 –

+0

在我的應用程序下載文件和上傳文件在收件箱中工作發現,但我不能刪除文件或文件夾和替換文件可以提供我的代碼? –

回答

0

這實際上是一個貧窮的問題,應該downvoted,因爲你沒有提供任何事物的例子你已經嘗試過了。

但一般來說,對於很多Restful服務器API(包括DropBox的一個)you first need to authenticate (i.e. get a token to prove that it's really you)

使用該令牌,您可以調用"fileops/delete" API,該API允許刪除文件或文件夾。

還有一個SDK that might encapsulate (or abstract)就足夠了,所以刪除和替換可能比試圖找出JSON & API更容易。

+0

在Dropbox的我的應用程序下載文件,上傳文件時,它的工作找到,但我不能刪除文件或文件夾並替換文件可以提供給我的代碼? –

+0

你好邁克爾Dautermann, 你能證明我的任何解決方案? –

0
You can do it using following code: 
-(void)deletefile:(DBPath *)filePath 
{ 
    NSError *err=nil; 
    BOOL success; 


    success=[[DBFilesystem sharedFilesystem] deletePath:filePath error:&err]; 
    if(success) 
    { 
     NSLog(@"deleted"); 

    } 
    else 
    { 
     NSLog(@"deletion error %@",err); 
    } 

} 
You need to use sync API:Check this API documentation for more detail: 

https://www.dropbox.com/developers/sync/docs/ios#DBFilesystem.deletePath:error

相關問題