从Dropbox下载文档目录中的文件将删除我的所有文件 [英] Downloading a file from Dropbox for documents directory deletes all my files
问题描述
我的应用程式显示dropbox档案和文件目录。当查看保管箱文件时,我可以按一个按钮,显示所有我的文档文件夹的列表,以及这些文件夹中的子目录,以便他们可以选择他们想要放在文档中的文件夹。当这样做时,我使用dropbox的客户c API,他们说在文档中使用的文件下载到系统中的路径。
My app shows dropbox files, and the documents directory. when viewing dropbox files i can press a button that shows a list of all my document folders, and subdirectories in those folders so they can chose the folder they want to put that file in the documents. when doing this i used dropbox's objective c API they say to use in the documentation to download a file into a path on the system.
NSString *DocumentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
for (NSIndexPath *indexPath in [dropboxFilesTable indexPathsForSelectedRows]) {
DBMetadata *fileMetadata = [[dropboxFolderMetadata contents] objectAtIndex:indexPath.row];
[[self restClient] loadFile:fileMetadata.path intoPath:DocumentsPath];
}
保管箱的委托人说它成功放在里面,回到,每个文件夹和下载的文件已被删除,该文件仍然不在文件夹中。我认为它将需要最后的路径,如路径文件/文件名,但然后dropbox给出一个错误。
the delegate for the dropbox says it is successfully put inside, but when i went back in, every folder and downloaded file has been deleted and that file is still not in the folder. i thought it would need the final path like "path to documents"/"filename", but then dropbox gives a error for that. Anyone know why its deleting all my files and not putting it in my documents?
推荐答案
intoPath
参数需要是一个完整的文件名路径,而不是一个目录。您需要更新最后一行为:
The intoPath
parameter needs to be a full filename path, not a directory. You need to update the last line to something like:
NSString *filename = [fileMetadata.path lastPathComponent];
NSString *destPath = [DocumentsPath stringByAppendingPathComponent:filename];
[[self restClient] loadFile:fileMetadata.path intoPath:destPath];
同时确保你只是这样做会是文件而不是文件夹。
Also make sure that you are only doing this will files and not folders.
这篇关于从Dropbox下载文档目录中的文件将删除我的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!