I'm trying to write a simple csv file to a server using sftp.
Here's my code:
const insertSftpFiles = async (sftp: SFTPClient, path: string, countryCode: CountryCode, archivePath: string, file: any, connectionConfig: any) => {
const csvData = jsonConvertToCsv([{ "a": "1", "b": "2"}]);
const readStream = fs.createReadStream(csvData);
const remote = "/inbound/hello.csv";
sftp.connect(connectionConfig).then(() => {
return sftp.put(readStream, remote);
})
.then(() => {
return sftp.end();
})
.catch(err => {
console.error(err.message);
});
}
My csvData is a proper csv string and i can connect to my server and even get files but when I try put I get this error:
Error: ENOENT: no such file or directory, open '"a","b" "1","2"'