Created
December 22, 2011 05:01
-
-
Save Superbil/1508976 to your computer and use it in GitHub Desktop.
uploadPhoto to Google Contact
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (GDataEntryContact *)uploadPhotoWithContactService:(GDataServiceGoogleContact *)contactService contact:(GDataEntryContact *)targetContact photoData:(NSData *)photoData | |
{ | |
GDataEntryBase *uploadPhotoEntry = [GDataEntryBase entry]; | |
// file path on iOS don't need | |
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:nil | |
defaultMIMEType:@"image/*"]; | |
[uploadPhotoEntry setUploadMIMEType:mimeType]; | |
[uploadPhotoEntry setUploadData:photoData]; | |
// |setShouldUploadDataOnly| will only upload data without entry data | |
[uploadPhotoEntry setShouldUploadDataOnly:YES]; | |
NSURL *postURL = [[targetContact photoLink] URL]; | |
__block GDataEntryContact *newContactEntry = nil; | |
__block NSError *newError = nil; | |
[contactService fetchEntryByUpdatingEntry:uploadPhotoEntry forEntryURL:postURL completionHandler:^(GDataServiceTicket *ticket, GDataEntryBase *entry, NSError *error) { | |
newContactEntry = (GDataEntryContact *)entry; | |
newError = error; | |
}]; | |
return newContactEntry; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment