2012-10-28 106 views
1

我有一个问题,钛加速器& Android。我想将互联网上的图像保存到SD卡中。我怎样才能做到这一点 ?钛 - 从互联网上保存图像到Android上的SD卡

var externalSrc = "http://example.com/image.jpg"; 

saveButton.addEventListener('click',function(e) { 
//?!? 
}); 

任何帮助将不胜感激,非常感谢。

回答

0

我还没有尝试Android上的代码,但在iOS上这很好。

var c = Titanium.Network.createHTTPClient(); 
var f = Titanium.Filesystem.getFile(directory, filename); // Here is the path to save the file. 
var url = '/url/to/image.jpeg'; 
c.onload = function() { 
    // File saved 
}; 

c.ondatastream = function(e) { 
    // Progress value in e.progress; 
}; 

c.onerror = function(e) { 
    // error 
}; 

c.open('GET', url); // open the client 
c.setFile(f); 
c.send(); // send the data