Automatically save a file and then download using HTML5

Discussion in 'Parallels Remote Application Server – HTML5 Gateway' started by RichardC11, Apr 29, 2019.

  1. RichardC11

    RichardC11 Bit poster

    Messages:
    3
    We have a published application and we do not want users storing files on our server. Also, our users just get confused using the HTML5 download feature. In our application , its easy to auto export a file when the user clicks on an icon. But my question is , is there a way to auto download it for the user to their download folder like other we apps do without the users having to do it ? Thanks Richard
     
  2. jpc

    jpc Pro

    Messages:
    449
    @RichardC11 At the moment, auto-download/upload of files is not possible.
     
  3. LeticiaM1

    LeticiaM1 Junior Member

    Messages:
    11
    OK, creating a data: URI definitely does the trick for me, thanks to Matthew and Dennkster pointing that option out! Here is basically how I do it:

    1) get all the content into a string called "content" (e.g. by creating it there initially or by reading innerHTML of the tag of an already built page).

    2) Build the data URI:

    uriContent = "data:application/octet-stream," + encodeURIComponent(content);
    There will be length limitations depending on browser type etc., but e.g. Firefox 3.6.12 works until at least 256k. Encoding in Base64 instead using encodeURIComponent might make things more efficient, but for me that was ok.

    3) open a new window and "redirect" it to this URI prompts for a download location of my JavaScript generated page:

    newWindow = window.open(uriContent, 'neuesDokument');
    That's it.
     

Share This Page