1

From iPhone i am trying to send oAuth Access token as http header to upload image to google blobstore service .I got the blob upload url fine but when I try to upload image I am getting NullPointer exception in upload handler servlet, saying user is null .I am using AFNNetwokring API . I pasted Exception and IOS code below .Please help.Thanks in advance.

NullPointer exception java.lang.NullPointerException at com.allyouralbums.servlets.AppContext.getCurrentUser(AppContext.java:91) at com.allyouralbums.servlets.UploadHandlerServlet.doPost(UploadHandlerServlet.java:45) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

- (void)postImage :(UIImage *) image
toUploadURI:(NSString*) blobServiceURL
withAuthentication:(GTMOAuth2Authentication*) auth{
NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager.requestSerializer setValue:[NSString stringWithFormat:@"Bearer %@", [auth   accessToken]] forHTTPHeaderField:@"Authorization"];
[manager POST: blobServiceURL parameters:nil  constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"FromIos" fileName:@"FromIos" mimeType:@"image/jpg;"];
 } success:^(AFHTTPRequestOperation *operation, id responseObject) {
   NSLog(@"Success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

}

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Sanu_Achu
  • 11
  • 2
  • I up-voted because I am having the same problem. Have you resolved this issue? I am having the same problem. I am trying to send an image to blobstore along with String metadata for the image. I am not able to send the metadata because its always null on server: http://stackoverflow.com/questions/25102155/afhttprequestoperationmanager-post-multi-part-request-not-working and http://stackoverflow.com/questions/25110365/how-to-convert-nsstring-to-uiimage-for-appengine-blobstore – learner Aug 04 '14 at 01:06

0 Answers0