i am new bie to titanium in my app i need to download and save a pdf file in iOS using titanium and the downloaded file can be accessible by third party pdf viewer applications.any help to achieve this thanks in advance.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
1- Make sure your webservice returns a PDF file.
2- Use the FileSystem to manage your files
var xhr = Titanium.Network.createHTTPClient({
onload : function() {
var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'file.pdf');
f.write(this.responseData);
tmpFile = Ti.Filesystem.createTempFile();
var newPath = tmpFile.nativePath + "." + f.extension();
Ti.API.info("newPath: " + newPath);
tmpFile = Ti.Filesystem.getFile(newPath);
tmpFile.write(f.read());
},
timeout : 10000
});
xhr.open('GET', 'your webservice');
xhr.send();
Now you use a pdf viewer and open the PDF from the externalStorageDirectory I tested on Android, it works !