You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2020/05/24 21:27:01 UTC

[GitHub] [royale-asjs] bigosmallm edited a comment on issue #838: mx.net.FileReference save method is not implemented

bigosmallm edited a comment on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633303391


   I believe you can initiate a download without the need for an explicit click action from the user.  This seems to work:
   
   ```var saveData = (function () {
       var a = document.createElement("a");
       document.body.appendChild(a);
       a.style = "display: none";
       return function (data, fileName) {
           var json = JSON.stringify(data),
               blob = new Blob([json], {type: "octet/stream"}),
               url = window.URL.createObjectURL(blob);
           a.href = url;
           a.download = fileName;
           a.click();
           window.URL.revokeObjectURL(url);
       };
   }());
   
   var data = { x: 42, s: "hello, world", d: new Date() },
       fileName = "my-download.json";
   
   saveData(data, fileName);
   ```
   
   Source: https://jsfiddle.net/koldev/cW7W5/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org