Unable to use filesystem "fs" in Freshdesk app

Hello Team,

I’m using the fs.createReadStream() method to read a CSV file from the SFTP server and got the following error. Could you please let me know if I’m missing anything?


const Client = require('ssh2-sftp-client');
const fs = require('fs');
const path = require('path');

exports = {
  onTicketCreateHandler: function () {
    let sftp = new Client();
      host: `hostname`,
      username: `username`,
      password: `password`,
      algorithms: { serverHostKey: ['ssh-rsa', 'ssh-dss'] }
    }).then(() => {
      return sftp.list('/file-path');
    }).then(data => {
      console.log('data', data[0].name);
      let fileWtr = fs.createReadStream(path.join(__dirname, data[0].name));
    }).catch(err => {
      console.log('err', err);


  "platform-version": "2.2",
  "product": {
    "freshdesk": {
      "events": {
        "onTicketCreate": {
          "handler": "onTicketCreateHandler"
  "whitelisted-domains": [
  "engines": {
    "node": "14.19.1",
    "fdk": "8.4.0"
  "dependencies": {
    "base-64": "1.0.0",
    "axios": "0.26.0",
    "mysql": "2.18.1",
    "ssh2-sftp-client": "9.0.4",
    "path": "0.12.7"


Access to the filesystem (and thus the fs module) is restricted in Freshworks apps. As is access to stream and buffer modules. That’s why you are seeing this error.

You don’t need the fs module for your use case though.

From the docs for the module, I see that the .list() method does not return file contents. It returns an array of objects representing items in the path listed. You should then use .get() to fetch the specific file. Once you get that file’s data, it will be as a String or a Buffer, which you can parse using a CSV parser.

Hope that helps.


Hello @kaustavdm, thank you for the response. It worked :slight_smile:

1 Like