I am trying to upload a file via SFTP.
The ssh2-sftp-client module connects to the server and path fine (verified with a list request). The file I want to upload is an XML built with the xml2js module.
The PUT method returns this error:
put: Bad path: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
//create new xml file
const builder = new xml2js.Builder();
const updatedXml = builder.buildObject(updatedFeed);
console.log("file length: ", updatedXml.length);
//upload new file
const sftp = new sftpClient();
await sftp.connect({
host: "example.com",
port: 22,
username: "user",
password: "password",
});
console.log("sftp connected");
const list = await sftp.list("/web/assets/exports");
console.log(list);
await sftp.put(updatedXml, "/web/assets/exports/feed_fixed.xml");
console.log("sftp put complete");
sftp.end();
}