Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download script using Titanium API
<body style="background-color:#1c1c1c;margin:0">
<div style="border-top:1px solid #404040">
<div style="color:#fff;;padding:10px">Welcome to Titanium</div>
<script type="text/javascript">
var url = '';
// Initialize the HTTPClient object
var httpClient = Titanium.Network.createHTTPClient();
// Connect to the url above
if ('GET', url)) {
// Create the temporary file
var file = Titanium.Filesystem.createTempFile();
// Set the path to desktop directory in our case
var filePath = Titanium.Filesystem.getDesktopDirectory().toString()+
// Copy the temporary file to our path
// Handle the reveived data (Titanium.Filesystem.File can also be used as a handler)
httpClient.receive(function(data) {
var file = Titanium.Filesystem.getFile(window['filePath']);
// Open the file created before and write to it the received data
var fileStream =;
} else {'cannot open connection');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment