All pastes #154714 Raw Edit

Someone

public javascript v1 · immutable
#154714 ·published 2006-08-30 15:26 UTC
rendered paste body
function test_get() {		//plugin.installPlugin('');	var data = {};	var e = {};	e.name = "tmp.pdf";	e.source = "http://the-erm.com/591-096811-007A.pdf";	var pluginDownloader = {		onStartRequest: function(req, c) {			var ary = e.source.match(/([^\/]+?)((\..{0,3}){0,2})$/);			data.of = plugin.getTempFile((ary ? ary[2] : undefined));			data.ofH = fopen(data.of, ">");		},		onDataAvailable: function(req, ctx, s, o, c) {			if (!data.is)				data.is = toSInputStream(s, true);			data.ofH.write(data.is.readBytes(c));		},		onStopRequest: function(req, ctx, code) {			data.ofH.close();			if (code == 0) {				alert("Done downloading.");			} else {				display("Error downloading: " + code, MT_ERROR);			}			try {				data.outFile.remove(false);			} catch(e) {}		}	};	try {		const ioSvc = getService("@mozilla.org/network/io-service;1", "nsIIOService");		var channel = ioSvc.newChannel(e.source, "UTF-8", null);		display("Downloading from '" + e.source + "'...", MT_INFO);		channel.asyncOpen(pluginDownloader, null);	} catch (ex) {		alert("Error downloading: ");		return;	}	}