Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: How can I read a text file inside the .xsjs?

$
0
0

There is no API that allows you to access the file system of the server in XSJS. You would need to upload the file from the client side and it will appear as a array buffer in the request object.  From there you can convert the array buffer to a string and process however you like.

 

For example:

 

  var content = "";

    content = $.request.body.asArrayBuffer();

    var array = new Uint8Array(content);

    var encodedString = String.fromCharCode.apply(null,array),

         decodedString = decodeURIComponent(escape(encodedString));

        content = decodedString;

 

 

    var lines = content.split(/\r\n|\n/);


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>