Possibility to save a file as download

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
Stefan Schnell
Posts: 46
Joined: Tue Dec 01, 2015 8:17 am
Contact:

Possibility to save a file as download

Post by Stefan Schnell »

Hello Fred,

a suggestion for a future release, is a function to save a file as download. Here my example for a binary database file:

Code: Select all


  ; Sub btnSaveEvent----------------------------------------------------
    Procedure btnSaveDBEvent()

      ; Variables-------------------------------------------------------
        Protected b64enc.i, link.i

      !v_b64enc = btoa(String.fromCharCode.apply(null, v_dbase.export()));
      !v_link = document.createElement("a");
      !v_link.setAttribute("href", "data:application/octet-stream;base64," + v_b64enc);
      !v_link.setAttribute("download", "test.sqlite");
      !v_link.click();

    EndProcedure

Thanks in advance.

Cheers
Stefan