title: Unable to get File name of image captured with camera
body: <p>I'm trying to build an app in which I'm able to capture image with camera and save to gallery. But I'm unable to get the file name of image. If I select image from camera roll, then I'm able to get file name of selected image.But when I capture image with camera in my app, It returns file name "<code>null</code>". Here is my code to save and select image from gallery using <code>UIImagePickerController</code></p>
  
  <pre class="lang-m prettyprint-override"><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  {
  
      UIImage *chosenImage = [self scaleAndRotateImage:[info valueForKey:UIImagePickerControllerOriginalImage]];
      NSString *mediaType = info[UIImagePickerControllerMediaType];
         self.userProfileImage.image = chosenImage;
  
      if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
          UIImage *image = info[UIImagePickerControllerOriginalImage];
  
          if (newMedia)
              UIImageWriteToSavedPhotosAlbum(image,
                                             self,
                                             @selector(image:finishedSavingWithError:contextInfo:),
                                             nil);
      }
  
      imageRotation=[NSString stringWithFormat:@"%f %f %f",acos (self.userProfileImage.transform.a), asin (self.userProfileImage.transform.b), atan2(self.userProfileImage.transform.b, self.userProfileImage.transform.a)];
      CGFloat angle = [(NSNumber *)[self.userProfileImage valueForKeyPath:@"layer.transform.rotation.z"] floatValue];
      NSLog(@"%f", angle);
  
      NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
      ALAssetsLibrary *assetLibrary = [ALAssetsLibrary new];
  
      [assetLibrary assetForURL:referenceURL
                    resultBlock:^(ALAsset *asset) {
                        ALAssetRepresentation *assetRep = [asset defaultRepresentation];
                       fileName = [assetRep filename];
                        NSLog(@"File name = %@", fileName);    
                    }
  
                   failureBlock:^(NSError *error) {
                       NSLog(@"%@", error);
                   }];
  
      [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
      [[UIApplication sharedApplication] setStatusBarHidden:YES];
      [picker dismissViewControllerAnimated:YES completion:nil];
      imageChanged=TRUE;
  }
  </code></pre>
  
  <p>And this code to save captured image</p>
  
  <pre class="lang-m prettyprint-override"><code>- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
      UIAlertView *alert;
      //NSLog(@"Image:%@", image);
        if (error) {
          alert = [[UIAlertView alloc] initWithTitle:@"Error!"
                                             message:[error localizedDescription]
                                            delegate:nil
                                   cancelButtonTitle:@"OK"
                                   otherButtonTitles:nil];
          [alert show];
  
      }
  }
  </code></pre>
  
  <p>I'm stuck at the point that how can I get file name of captured image.
  What wrong I'm doing in my code ? Please suggest me any correction or solution. Any help would be appreciated . Thanks in advance</p>