Forum Discussion

Chez B.'s avatar
Chez B.
New member | Level 1
11 years ago

How do I upload a file to my dropbox apps folder in dropbox in objective c?

Currently nothing happens when I run my code.

This is how I am setting the up client. I did not put the client set up in my viewDidLoad method because this class will never be shown it just handles server side actions.

(instancetype)initWithClient  
{

  self = [super init];

  if (self) {

    self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];

    self.restClient.delegate = self;

      }

  return self;  
}  



This is how I make the API call to upload

(void)uploadToDropBox:(UIImage *)img  
{

  NSLog(@"Entered the DB upload method");


  NSArray *directories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
                                                             NSUserDomainMask,  
                                                             YES);


  NSString *documentDirectory = [directories firstObject];

  NSString *imagePath = [documentDirectory stringByAppendingPathComponent:@"cardImage"];

  NSString *destDir = @"Apps/BirthdayScrapbook";

  NSLog(@"Just about to execute the upload method");

  NSData *imageData = UIImagePNGRepresentation(img);

  [imageData writeToFile:imagePath atomically: YES];

  [self.restClient uploadFile:@"cardImage" toPath:destDir withParentRev:nil fromPath:imagePath];

  NSLog(@"Executed the DB  upload method");

  [self sendBDayCard];  
}  



I think I am going about it wrong. I know what my access token is, but I don't know what to do with it nor where to put it. There is a client init method that takes in the userID, but I don't know where to find my accounts userID. Can someone give some direction with this?

17 Replies

Replies have been turned off for this discussion

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!