rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: rejetto on October 26, 2009, 01:35:04 AM

Title: downloading big files
Post by: rejetto on October 26, 2009, 01:35:04 AM
hello,
referring to this post (http://www.rejetto.com/forum/index.php?topic=7668.msg1046929#msg1046929)
you can download a file by using commands {.load.} and {.save.}

{.load|http://rejetto.com/hfs/download|var=#x.}
{.save|test.exe|var=#x.}

the url in the example will download HFS program.
but this may lead to memory problems for bigger files, so this is a script to download the file 1MB at time

Quote
{.set|#url|http://surfnet.dl.sourceforge.net/project/nmapwin/nmapwin/1.3.1/nmapwin_1.3.1.exe.}
{.set|#out|test.}

{.set|#from|0.}
{.set|#chunk|1000000.}
{.save|{.^#out.}|.}
{.while|#chunk|{:
   {.load|{.^#url.}|var=#x|size={.^#chunk.}|from={.^#from.}.}
   {.if|{.length|var=#x.}
      | {:{.append|{.^#out.}|var=#x.}
         {.inc|#from|{.length|var=#x.}.}
        :}
      | {:{.set|#chunk|0.}:}.}
:}|timeout=0.}

all variables are in the #global form because i made this in the "run script" window.
i wish someone to continue this work and get something people can integrate in their template.

this requires some bugfixes available in #248 that i'm going to publish now.

because of the bugs, this took me 2 hours   :'(