title: Uploading image from gallery with AFNetworking 3.0
body: <p>I checked the code <a href="https://github.com/AFNetworking/AFNetworking#creating-an-upload-task-for-a-multi-part-request-with-progress" rel="nofollow">example</a> to upload images via multipart.
  But I don't know how get the @"file://path/to/image.jpg" value.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>-(void) uploadAvatar:(NSString*)file
  success:(void (^)())success failure:(void (^)())failure {
  
  
      NSString* url = [NSString stringWithFormat:@"%@%@%@", res, kApiRest, kApiServiceAvatar];
      //NSString* filepath = [NSString stringWithFormat:@"%@%@", res, kApiRest];
  
  
  
      NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:url parameters:nil constructingBodyWithBlock:^(id&lt;AFMultipartFormData&gt; formData) {
          [formData appendPartWithFileURL:[NSURL fileURLWithPath:file] name:@"file" fileName:@"image.jpg" mimeType:@"image/*" error:nil];
      } error:nil];
  
      //AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  
      NSURLSessionUploadTask *uploadTask;
      uploadTask = [self.manager
                    uploadTaskWithStreamedRequest:request
                    progress:^(NSProgress * _Nonnull uploadProgress) {
                        // This is not called back on the main queue.
                        // You are responsible for dispatching to the main queue for UI updates
                        dispatch_async(dispatch_get_main_queue(), ^{
                            //Update the progress view
  //                          [progressView setProgress:uploadProgress.fractionCompleted];
                        });
                    }
                    completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
                        if (error) {
                            NSLog(@"Error: %@", error);
                            failure();
  
                        } else {
                            NSLog(@"%@ %@", response, responseObject);
                            success();
                        }
                    }];
  
      [uploadTask resume];
  }
  
  
  #pragma mark - UIImagePickerControllerDelegate
  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      [self dismissViewControllerAnimated:YES completion:nil];
  
      NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
      UIImage *imageToUse;
  
      // Imagen
      if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo) {
          imageToUse = (UIImage *) [info objectForKey: UIImagePickerControllerEditedImage];
          imageToUse = [imageToUse scaleToMaxWidth:kAvatarSize];
  
  
          NSData* fileHD = UIImagePNGRepresentation(imageToUse);
          APIAvatar* api = [[APIAvatar alloc] initWithUser:_user.jid password:_user.pass];
          //I have the NSData object fileHD, how can I get the path?
          [api uploadAvatar:[fileHD ] success:&lt;#^(void)success#&gt; failure:&lt;#^(void)failure#&gt;]
      } 
  }
  </code></pre>