title: How to upload/download a file from/to dropbox using Xcode
body: <p>How could I upload/download a file from/to dropbox? I integrated dropbox applications in my app, but I couldn't upload/download a file.</p>
  
  <p>This is my upload code:</p>
  
  <pre><code>- (NSString *)getDocumentPath
  {
      NSMutableData * pdfData = [NSMutableData data];
      UIGraphicsBeginPDFContextToData(pdfData, self.view.bounds, nil);
      UIGraphicsBeginPDFPage();
      CGContextRef pdfContext = UIGraphicsGetCurrentContext();
      [self.view.layer renderInContext:pdfContext];
      UIGraphicsEndPDFContext();
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  
      NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"vani.doc"];
  
      [pdfData writeToFile:path  atomically:YES];
  
      return path;
  }
  
  - (IBAction)upload:(id)sender {
  
      NSString *path = [self getDocumentPath];
  
      NSString * local = [path lastPathComponent];
  
      NSString *destDir = @"/Plist Folder/vani.doc";
  
      [restClient uploadFile:local toPath:destDir withParentRev:nil fromPath:path];
  </code></pre>
  
  <p>This is for downloading:</p>
  
  <pre><code>    restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
      restClient.delegate = self;
      NSString *fileName = [NSString stringWithFormat:@"/vani.doc"];
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                           NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
  
      NSString *path2 = [documentsDirectory stringByAppendingString:
                         [NSString stringWithFormat:@"%@", fileName]];
      //NSLog(@"%@", path2);
  
      [restClient loadFile:fileName intoPath:path2];
  </code></pre>