Here is a quick process flow that I am trying to implement:
- User selects an existing Camera Roll image or video.
- The app FTPs the selected image out to a remote FTP server.
Pretty straight forward, or so it seems!
So far I can get the UIImagePickerController to allow the user to select an image from the Camera Roll and can get a NSURL of the image with:
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
this returns something like:
assets-library://asset/asset.JPG?id=ACE09510-60D8-41EF-BC26-0A0A4D57B21C&ext=JPG
Now, jumping ahead to part 2, I can successfully FTP a file to a remote server using the CFNetwork framework.
The missing link here seems to be converting the assets-library formatted NSURL (*assetURL) to a standard file format URL that NSFileManager uses.
If I use a hard-coded file URL pointing at a .jpg already in my application bundle I can successfully FTP it out. However, if I use the assets-library formatted URL I get zero bytes at the other end.
My question is just how do I convert the assets-library URL to a regular file URL? I've seen examples of how to copy a Camera Roll image to my Documents directory. And then I guess I could use that file URL to send the image. However, if I am planning on sending video, it would not be very wise to copy an huge file to the Documents directory just to FTP it out.
I do realize that FTP is not the protocol of choice, and is wrought with holes. However, it is an existing FTP server, and I have been told "thow shalt use it" by the powers that pay me.
I am obviously missing a concept or two on how to implement this. Many thanks ahead of time to anyone who can point me in the right direction.