titaniumtitanium-mobileappcelerator-mobile

Titanium Mobile - PhotoGallery - Success callback - event property - media.file returns null


Titanium SDK: 2.1.1, Host OS: Mac OS X 10.6.8, Mobile platform: iOS 5

I am un-able to access some properties of 'Blob' object returned by Titanium.Media.openPhotoGallery's success callback. The properties un-accessible are 'file' and 'nativePath', however I can access properties like 'height', 'width' and 'mimeType'. I'm testing on simulator.

Here is what I coded so far.

Titanium.Media.openPhotoGallery({
    success : function(event) {

        var image = event.media;

        if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {

            // following properties are accessible
            Ti.API.info(' event.media = ' + event.media );
            Ti.API.info('event.media.height = ' + event.media.height );
            Ti.API.info('event.media.width = ' + event.media.width );
            Ti.API.info('event.mediaType = ' + event.mediaType );

            // following properties are un-accessible
            Ti.API.info(' event.media.nativePath = ' + event.media.nativePath );
            Ti.API.info(' event.media.file = '  + event.media.getFile() );              
    },
    cancel : function() {},
    error : function(error) {},
    allowEditing : true,
    mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});

Solution

  • You cannot access file or file native path from iphone photo gallery. its not accessible. although you can store the selected image on file system or sqlite db and then perform all your tasks on it ...:)