Thursday, September 13, 2007

download issues on saicast

The Hariharan video on saicast attracted a large number of downloads, mostly from India, so the inefficiencies of the code were exposed. Server ran out of memory pretty quickly. Changed the ADODB.Stream object's buffering to be more sane - from code snippet at http://www.webservertalk.com/archive120-2004-8-342917.html
found by googling ADODB.Stream large file
for i = 0 to objStream.size
i = i + 128000
Response.BinaryWrite(objStream.Read(128000))
Response.Flush
next
My earlier trials along same lines did not work when I tried the Binarywrite and the Read calls in different lines, probably since I didn't save the Read's return value in a variable or something. When it had not worked, briefly tried a javasript-based solution:
<script language="JavaScript" type="text/JavaScript">
function forcedown(x){
myTempWindow = window.open(x,’’"SSS"’);
myTempWindow.document.execCommand(’"SaveAs"’,null,x);
myTempWindow.close();
}
</script>
....
<a href="javascript://" onclick="forcedown('http://downloads.radiosai.org/filename.wmv');">dwnld</a>
The experts exchange link had some small syntax problems like SaveAs not within quotes, script tag not having the language=Javascript etc. Abandoned this as unsuitable because IE6 on WinXP was playing the file in Windows Media Player instead of showing the download box. Firefox, Konqueror, IE7 etc worked, Safari also did not work.

No comments:

Post a Comment