3

Here is a quick process flow that I am trying to implement:

  1. User selects an existing Camera Roll image or video.
  2. 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.

Undo
  • 25,519
  • 37
  • 106
  • 129
Randy Mennie
  • 123
  • 2
  • 7

1 Answers1

2

Unfortunately, you do not get file-level access to the Assets directory in iOS (which explains why you can't reference the photo file itself), but you should still be able to do what you need using the ALAssetLibrary to create an image from the data stored at the URL. Check out the answer to this question, which shows how to create a UIImage using the ALAssetRepresentation object. Using this technique, you should be able to obtain the image data needed to send to the FTP server.

Community
  • 1
  • 1
Mike Fahy
  • 5,487
  • 4
  • 24
  • 28