I have an iphone app where I want to upload a file on phone's local disk to user's dropbox. I want to give the user an option to upload it to anywhere in his dropbox. I have seen many apps do this but haven't found any example online that takes me through a step by step tutorial. Any pointers will be helpful!
EDIT :
//setup
DBSession* dbSession = [[DBSession alloc] initWithAppKey:@"XXX"
appSecret:@"XXX"
root:kDBRootDropbox];
[DBSession setSharedSession:dbSession];
[self handleDropboxSession];
DBRestClient *restclient = [[DBRestClient alloc] initWithSession:dbSession];
restclient.delegate = self;
[NSTimer scheduledTimerWithTimeInterval:5.0f block:^{
[self testSaveFileToDBox:restclient];
} repeats:NO];
//relevant methods
-(void)testSaveFileToDBox:(DBRestClient *)client
{
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSString *filename = @"working-draft.txt";
NSString *destDir = @"/";
[client uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];
}
- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath
from:(NSString*)srcPath metadata:(DBMetadata*)metadata {
NSLog(@"File uploaded successfully to path: %@", metadata.path);
}
- (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error {
NSLog(@"File upload failed with error - %@", error);
}
-(void)restClient:(DBRestClient *)client uploadProgress:(CGFloat)progress forFile:(NSString *)destPath from:(NSString *)srcPath{
NSLog(@"upload progress");
}
The file "working-draft.txt" does not exist but then the error delegate method is not getting called. FWIW, this all is in app delegate.
Closest thing is https://github.com/goosoftware/GSDropboxActivity. It seems dropbox does not provide an official "folder chooser" so all these apps are rolling out their own custom solution like the one I show above.