Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Writing an image file to application data directory in BB10 seems impossible

$
0
0

Hi guys,

In my app, I'm opening the camera, taking a photo, and writing the file to the applicationDataDirectory folder, then saving the path to an SQLite DB. I'm trying to write to the directory because BB10 won't give me a nativePath to images saved in the gallery.

Works fine on Android, however the lack of Blob functionality for BB10 is figuratively ruining my life. Here's my code. Any workarounds / alternatives would be greatly appreciated.

I am developing on Blackberry Z10.

(PS. Yes, I have the correct permissions declared in the manifest.)

Titanium.Media.showCamera({
    'saveToPhotoGallery' : true,
    'success' : function(image) {
 
        Ti.API.info("image.media: " + image.media); // [INFO] image.media: [object Blob]
        Ti.API.info("mimeType: " + image.media.mimeType); // [INFO] mimeType: 
 
        var fileExtension = image.media.mimeType.split('/')[1];
 
        Ti.API.info("fileExtension: " + fileExtension); // [INFO] fileExtension: undefined
 
        var fileStem = Math.floor((Math.random() * 10000) + 1) + "." + fileExtension;
 
        var imageFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fileStem);
 
        Ti.API.info("imageFile : " + imageFile); // [INFO] imageFile : [object TiFilesystemFileProxy]
 
        if (OS_BLACKBERRY) {
            if (!imageFile.exists()) {
                imageFile.createFile();
            }
        }
 
        var test = imageFile.write(image.media);
 
        Ti.API.info("test if file is written: " + test); // [INFO] test if file is written: false
 
        Ti.API.info("imageFile.read().length : " + imageFile.read().length); // [INFO] imageFile.read().length : 0
 
    }
});

Thanks in advance


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>