0

I'm trying to upload an image to dropbox. I'm using the latest version of the SDK (Sept. 17) and have successfully authenticated my app.

Here's the code that does it:

for ( NSUInteger i = 0; i < [photos count]; i ++ ) {

    NSString *filename = [NSString stringWithFormat:@"%d.png", i+1];
    NSString *file = [NSTemporaryDirectory() stringByAppendingPathComponent:filename];

    [UIImagePNGRepresentation([photos objectAtIndex:i]) writeToFile:file atomically:YES];

    NSString *destDir = @"/";
    [self.dropboxClient uploadFile:filename toPath:destDir withParentRev:nil fromPath:file];

}

Note:

  • self.dropboxClient is an instanced DBRestClient object.
  • photos is an NSMutableArray of UIImages (I already checked to make sure that the objects are images using the NSStringFromClass() method on each object in the list);

Most importantly, I think there may be an issue with my DBRestClient object (self.dropboxClient), since none of the delegate methods are entered even though I've set the delegate.

Any and all help would be greatly appreciated!

ArtSabintsev
  • 5,170
  • 10
  • 41
  • 71
  • Does this help? http://stackoverflow.com/questions/8942185/upload-image-from-uiimageview-using-dropbox-sdk-for-iphone – snibbets Oct 11 '12 at 01:22
  • Or this one (self is being deallocated)? http://stackoverflow.com/questions/10248034/dropbox-api-in-ios-how-to-use-dbrestclient – snibbets Oct 11 '12 at 01:31
  • @snibbets already saw those - they didn't work :\ - I just double checked, one of my dozens of images did end up syncing eventually. I'm really not sure what's going on. It may be an issue with Dropbox. – ArtSabintsev Oct 11 '12 at 02:04
  • It was an issue with threads. DBRestClient has to run on the main thread, and it wasn't doing that. – ArtSabintsev Oct 11 '12 at 06:19

1 Answers1

2

This was a threading issue. DBRestClient methods, like createFolder and uploadFile:::: must be executed on the main thread.

ArtSabintsev
  • 5,170
  • 10
  • 41
  • 71