Author Topic: [Question] How to download and save an external file (Macro)  (Read 2763 times)

Offline danny

  • Occasional poster
  • *
  • Posts: 43
    • View Profile
{.load|http://distro.ibiblio.org/tinycorelinux/9.x/x86/release/Core-9.0.iso|/Upload.}
That loads 5596 bytes of the iso into ram.  Needs the {.save


However, from rejetto's posts, I found an example of saving big files 
Except that the chunk size maximum is bigger than the buffer, which may fill and exit.
{.set|#url|http://distro.ibiblio.org/tinycorelinux/9.x/x86/release/Core-9.0.iso.}
{.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.}

I guess you could try the chunk size at 4096 if that is bytes or 32768 if bits?  Hard drives write 4k chunks.  Even 5k might work; but, larger would probably exit the script before it could append more.
Might want to replace "test" with the destination?  Folder or filename?
Seems that "Remote Upload" is in alpha status. 

P.S.
Maybe Openmediavault has Remote Upload for your Raspberry Pi? 

« Last Edit: May 20, 2018, 01:11:01 PM by Mars »

Follow members gave a thank to your post: