Why can't this create a new file on the remote server? "no such file or directory"
See original GitHub issueThe issue is present in the example code for me
let Client = require('ssh2-sftp-client');
let sftp = new Client();
sftp.connect({
host: '...',
port: '...',
username: '...',
password: '...'
}).then(() => {
return sftp.fastPut('./test.txt', '/tf/maps/test.txt') //this doesn't work unless a '/tf/maps/test.txt' already exists which it will overwrite
//return sftp.put(require(`fs`).createReadStream('./test.txt'), '/tf/maps/test.txt') //Same issue as above
//return sftp.list('/tf/maps/') //This works
}).then(data => {
console.log(data, 'the data info');
}).catch(err => {
console.log(err, 'catch error');
});
I get the error Error: fastPut->exists->_stat: open /var/lib/pufferd/servers/18a5d777-a56d-4d07-a6f4-7d0e3f619081/tf/maps/test.txt: no such file or directory /tf/maps/test.txt
for fastPut and put, unless I already have a test.txt on the remote server.
Does this package only overwrite existing files? I have no idea how to actually create a remote file
In the readme it says remotePath: string. Path to the remote file to be created on the server.
which suggests that it should create the file yet refuses to write unless it’s already there.
I have the server open in Filezilla and am able to create files there so I don’t think it’s a permission issue.
I have also tried explicitly giving the flag w
, and tried different modes as if that would do anything
Node: 14.7.0 OS: tried on Windows 10, Debian 4.19.118, and Ubuntu 18.04.4 ssh2-sftp-client: 5.2.1 Server is using https://github.com/PufferPanel/pufferd
Full errors:
Error: put->exists->_stat: open /var/lib/pufferd/servers/18a5d777-a56d-4d07-a6f4-7d0e3f619081/tf/maps/test.txt: no such file or directory /tf/maps/test.txt
at Object.formatError (C:\Users\x\source\repos\sftptest\sftptest\node_modules\ssh2-sftp-client\src\utils.js:62:18)
at SftpClient.put (C:\Users\x\source\repos\sftptest\sftptest\node_modules\ssh2-sftp-client\src\index.js:740:19)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 'ERR_GENERIC_CLIENT',
custom: true
} catch error
Error: fastPut->exists->_stat: open /var/lib/pufferd/servers/18a5d777-a56d-4d07-a6f4-7d0e3f619081/tf/maps/test.txt: no such file or directory /tf/maps/test.txt
at Object.formatError (C:\Users\x\source\repos\sftptest\sftptest\node_modules\ssh2-sftp-client\src\utils.js:62:18)
at SftpClient.fastPut (C:\Users\x\source\repos\sftptest\sftptest\node_modules\ssh2-sftp-client\src\index.js:652:19)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 'ERR_GENERIC_CLIENT',
custom: true
} catch error
Debug of fastPut https://pastebin.com/8AfrzSwE
When I already made a blank test.txt
test.txt was successfully uploaded to /tf/maps/test.txt! the data info
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (13 by maintainers)
Top GitHub Comments
Fix released in v5.2.2
Just looking more closely at the error message and the server code, can you verify the server supports the stat() method e.g.
sftp.stat(/path/to/remote/file’);
I suspect the command is not supportedor it is returning data in a non-comnpliant manner.
run the command with argument for a file which exists, a file which does not exist and a directory which exists. Send me the results.