从Titanium中的Amazon S3 Bucket下载文件

时间:2013-02-16 09:27:58

标签: iphone ios amazon-s3 titanium titanium-mobile

我想知道使用Appcelerator Titanium从Amazon S3 Bucket下载文件对象的方法。

任何人都可以帮助我吗

提前致谢

1 个答案:

答案 0 :(得分:0)

 var downloadingFileUrl = "Url of the file that need to be downloaded"

//File path where downloaded file will be saved
var fileSavingPath = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,"file_Path");

 //Define the http client
 var myHttpClient = Ti.Network.createHTTPClient();

//On success of downloading
myHttpClient.onload = function(){

 //Write the file to the desired path
fileSavingPath.write(httpClient.responseData);
};

//Open the url to download
myHttpClient.open("GET",  downloadingFileUrl);

//Send request
 myHttpClient.send(null);