2016-08-31 35 views
2

我使用ObjectiveDropbox來管理用戶的Dropbox帳戶的一些任務,即列出文件並下載其中的一些。下載錯誤:CFNetworkDownload_ <some id> .tmp無法移動到「」,因爲已存在同名項目

清單從我的帳戶中的文件和文件夾是相當straigt進,但是當我想下載一個文件,我得到這個錯誤: download error: CFNetworkDownload_<some id>.tmp couldn't be moved to <unique ID> because an item with the same name already exists.

任何想法,爲什麼?這確實下載

代碼:

 DropboxDownloadArg *downloadArg = [[DropboxDownloadArg alloc] initWithPath:metadata.pathLower]; 
NSURL *destURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]]; 
     [self.dropboxClient.files download:downloadArg 
         destFileUrl:destURL 
          progress:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) { 

          } success:^(DropboxFileMetadata * _Nonnull metadata) { 
           [self.downloadDelegate downloadHasCompletedSuccessfully]; 
          } fail:^(DropboxError * _Nonnull error) { 
           NSLog(@"download error: %@", error.errorSummary); 
           [self.downloadDelegate downloadFailed]; 
          }]; 

我檢查了downloadArg和destURL正確創建和有效。

謝謝

+0

...即使你重新模擬器/設備app文件夾出現這種情況? – eddyce

+0

是的。我從設備上刪除了應用程序,然後再次嘗試。 – invalidArgument

+0

你在你的應用中使用https://github.com/AFNetworking/AFNetworking嗎? – eddyce

回答

3

我剛剛轉載了您的問題。看起來問題出現在您的destinationURL中。 當你結合不同的路徑並將它們從NSURL轉換爲NSString並返回時,你可以得到這樣的路徑:file:/// file:/ ... 檢查示例項目。它使用臨時目錄並且運行良好。

這裏是Documents目錄的工作代碼:

NSURL *dir = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; 

NSURL *filePath = [dir URLByAppendingPathComponent:@"file.f"]; 

[self.dropbox.files download:downloadArg destFileUrl:filePath progress:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) { 
相關問題