cancel
Showing results for 
Search instead for 
Did you mean: 

How to write file to a UNIX file system from XSJS?

Hi,

I want to write the xsjs response in a .dat file. I am able to write the response in .dat file and its being downloaded.

This is the below code.

 $.response.setBody(strF);
  $.response.contentType = 'application/vnd.ms-excel; charset=utf-16le';
  $.response.headers.set('Content-Disposition','attachment;filename=POC3.dat');
  $.response.status= $.net.http.OK;

But I want to restrict the download part and write this file "POC3.dat" in UNIX file system.

All these needs to be done through XSJS only. I am using XS advanced.

Any lead would be appreiated.

View Entire Topic
thomas_jung
Developer Advocate
Developer Advocate

There is no file system API specifically in XSJS. As you said this is XS Advanced, why not use regular Node.js for this part. It can write easily to the file system of the XSA server (not necessarily the same as the file system of the HANA DB in a distributed environment).
https://www.w3schools.com/nodejs/nodejs_filesystem.asp

0 Kudos

Hi Thomas,

I need to write file into remote UNIX server from XSA server. I read a blog that its not possible to write to a remote server using fs module in node js.