-1

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];
}

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?

Andriy
  • 2,767
  • 2
  • 21
  • 29
Maximilian Litteral
  • 3,059
  • 2
  • 31
  • 41

1 Answers1

1

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • i get a couple errors, `[ERROR] DBRequest#connectionDidFinishLoading: error moving temp file to desired location: The operation couldn’t be completed. (Cocoa error 512.)`, `[WARNING] DropboxSDK: error making request to /1/files/dropbox/Textastic/Personal Website/Crux.html - (512) Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)" UserInfo=0x1fd4dfd0 {path=/Textastic/Personal Website/Crux.html, destinationPath=/var/mobile/Applications/4FAFE75B-D00C-4BA1-8E9B-FD94DB1F5249/Documents/Crux.html}` using http://pastie.org/5358285 – Maximilian Litteral Nov 11 '12 at 00:11
  • 1
    Your Documents directory may be trashed from your earlier issues. Delete the app and do a fresh install so the sandbox is created again properly. – rmaddy Nov 11 '12 at 00:15