diff --git a/armory/Sources/armory/logicnode/WriteFileNode.hx b/armory/Sources/armory/logicnode/WriteFileNode.hx index 2fe87a16b..4e3e8850c 100644 --- a/armory/Sources/armory/logicnode/WriteFileNode.hx +++ b/armory/Sources/armory/logicnode/WriteFileNode.hx @@ -15,6 +15,15 @@ class WriteFileNode extends LogicNode { var path = Krom.getFilesLocation() + "/" + file; var bytes = haxe.io.Bytes.ofString(data); Krom.fileSaveBytes(path, bytes.getData()); + + #elseif kha_html5 + var blob = new js.html.Blob([data], {type: "application"}); + var url = js.html.URL.createObjectURL(blob); + var a = cast(js.Browser.document.createElement("a"), js.html.AnchorElement); + a.href = url; + a.download = file; + a.click(); + js.html.URL.revokeObjectURL(url); #end } } diff --git a/armory/Sources/armory/logicnode/WriteJsonNode.hx b/armory/Sources/armory/logicnode/WriteJsonNode.hx index 8bd70c660..cb7160075 100644 --- a/armory/Sources/armory/logicnode/WriteJsonNode.hx +++ b/armory/Sources/armory/logicnode/WriteJsonNode.hx @@ -11,12 +11,20 @@ class WriteJsonNode extends LogicNode { var file: String = inputs[1].get(); var data: Dynamic = inputs[2].get(); var s = haxe.Json.stringify(data); - trace(s); #if kha_krom var path = Krom.getFilesLocation() + "/" + file; var bytes = haxe.io.Bytes.ofString(s); Krom.fileSaveBytes(path, bytes.getData()); + + #elseif kha_html5 + var blob = new js.html.Blob([s], {type: "application/json"}); + var url = js.html.URL.createObjectURL(blob); + var a = cast(js.Browser.document.createElement("a"), js.html.AnchorElement); + a.href = url; + a.download = file; + a.click(); + js.html.URL.revokeObjectURL(url); #end } }