Search code examples
iphonensfilemanager

Writing to the DCIM folder on iPad/iOS


I'm trying to write some images in the DCIM folder on an iPad, for good reasons: to allow the user to import these images to their Aperture or Lightroom without having to use the iTunes Shared Library (which is a 'broken feature', half done).

I tried to browse the filesystem to find the name of the folder and access it. It's supposed to be on

 /private/var/mobile/Media/DCIM/100APPLE

where 100APPLE can change.

Accessing that folder from the computer is possible, for example using PhoneView (great software from Ecamm). But doing it from the device seems impossible.

Here's the code I use to browse the folder, while searching for that:

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSFile *private = @"/private/var/mobile/Media/DCIM/";
NSLog(@"%@",[fileManager contentsOfDirectoryAtPath:private error:&error]);

This code works perfectly, but gives me a null array, when I should have at least "100APPLE". I looked at the PhotoData folder, which contains other pictures. Same story.

I know that if Apple made it "secret" is so that we don't write to it. But since we don't have access to assets library to write, and saving images using the API only savez the image, and no metadata (exif, whatever). And some apps do this.


Solution

  • Answering my own question, the one way to do it is to use the ALAsset way nowadays, with iOS 4 &5. Works well, keeps metadata.