0

How to do HTTP POST for images/videos picked from UIImagePickerControllerusing setHTTPBodyStream: of NSMutableURLRequest? I mean what is the best way to upload file from asset library in full quality, right from the file system (drive)? I hoped for creating inputStream for setHTTPBodyStream: with URL from UIImagePickerControllerReferenceURL but it doesn't work, system can't make inputStream for this URL...

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSURL *URL = [info objectForKey:UIImagePickerControllerReferenceURL];
    NSInputStream *inputStream = [NSInputStream inputStreamWithURL:URL]; // here I get just nil...

    ...
    [URLRequest setHTTPBodyStream:inputStream];
    ...
user500
  • 4,519
  • 6
  • 43
  • 56

1 Answers1

0

Using UIImagePickerController, you don't get a URL/path for the image (you do get it for videos). You will only get the UIImage. However if you want the original image, it is still available in the dictionary sent with this method.

Check out the answer here on how to upload the image.

Community
  • 1
  • 1
lostInTransit
  • 70,519
  • 61
  • 198
  • 274