Is there anyway to check whether a particular image file exists in my iPhone. Lets say my image name is IMG_123.JPG. I want to search this image and if it exists I want to create a NSInputStream object using that File. If the image is not in NSBundle it can be saved in photo library or somewhere.
Please help me. Thanks
UPDATE
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [pathArray objectAtIndex:0];
NSString* dataPath = [documentsDirectory stringByAppendingPathComponent:@"IMG_2594.JPG"];
UPDATE 2
Getting the image when user click the picker image
copyOfOriginalImage = [UIImage imageWithCGImage:[[imageAsset defaultRepresentation] fullResolutionImage]];
Convert the image into NSData
imageData = UIImageJPEGRepresentation(copyOfOriginalImage, 1.0);
Then I convert it into base64
strEncoded=[imageData base64EncodedStringWithOptions:0];
Your image can be at
documentdirectoryorassetsorappbundlein your application.Images which are located in
photolibrary, you can't called it part of your app's database.So, you can check that your image is available in
documentdirectoryor any directory liketempdirectoryorcustomdirectoryif you have made like,It will check directly in document directory. If you are making custom directory in document directory then provide path of it.
Now If your image is in app bundle then you can check it like,
If your image is in
asseststhen you can check it like,Now, for checking image is available in photo library, This is a bit critical task that you should have the list of all images and then you can check that it available or not. For that you have to use ALAssetsLibrary.
Refer This SO answer for managing this.
You can refer this so post also.