0
votes

i have this problem like 2 weeks and i don't know why. I'm using Ti.Paint and i want tos save the draw into a file, so, this is the code:

var paintImage=paintView.toImage().media;
    var tmpImg="paintImage.jpg";;
    var imageFile=Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, tmpImg);
    imageFile.write(paintImage);

And NOTHING happens, nothing at all, the action says "true", but the file does not exist in the Gallery, nor the Cellphone, nor the Android/data/appDirectory, nothing, just nothing. And i don't know why. I use this code to save an image from the camera to the gallery and works flawless:

success:function(event)
    {
        tmpImg="prueba.jpg";
        var imageFile=Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, tmpImg);
        imageFile.write(event.media);
    },

So, can anyone help?, because i have NO idea why this is not working.

Using

Titanium SDK 3.2.2GA with Alloy
Titanium Studio, build: 3.2.3.201404181442
MacbookPro 2012 with OSX Maverick
Device: Motorola XT910
2
No one?, i need help on this. - Oscar Gallo

2 Answers

0
votes

I believe this was fixed in Titanium 3.3.0 and was related to issue where the mimeType wasn't getting set properly (https://jira.appcelerator.org/browse/TIMOB-15746) Try updating and make sure that you change the Titanium SDK to 3.3.0 in tiapp.xml.

0
votes

in android, you the better to save the file in the Ti.Filesystem.externalStorageDirectory folder, you can try the below sample code:

var imageFile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, "paintImage.jpg");
if(!imageFile.exists()) {
     imageFile.write(event.media);
}