SFTP: FastGet returning Folder not found error
See original GitHub issueI’m having trouble downloading a file with the sftp fastGet method. Here is my code:
var client = new Client();
client.on('ready', function() {
client.sftp(function(err, sftp) {
sftp.fastGet('./file.zip', 'file.zip', function(err) {
client.end();
});
});
}).connect({
*connection_info*
});
I am getting the following error:
Error: Folder not found: \remote\pathHome\directory\file.zip
If I do a readdir:
sftp.readdir('./', function(err, filelist) { console.log(filelist); });
It lists file.zip as one of the files.
And if I do a realpath:
sftp.realpath('./', function(err, absPath) { console.log(absPath); });
It returns /home/directory (note the lowercase h on home)
I am not the administrator of the sftp server so can only assume that the \remote\path part of the error is some internal directory structure on the server.
Using node v4.2.1 and ssh2 v0.4.12
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Node.js - ssh2-sftp-client getting multiple files error
What I believe is currently happening is that since you're not returning a Promise from your second then() , the third then() gets...
Read more >ssh2-sftp-client - npm
If the remote file did not exist, the method would return an error, but failed to close any passed in stream supplied as...
Read more >ssh2-sftp-client-fork - npm Package Health Analysis | Snyk
The realPath() method now returns '' if the path does not exist rather than throwing an exception. Improved error handling.
Read more >Files changed (6) - Renovate Bot Package Diff
The realPath() method now returns `''` if the path does not exist rather than ... At least one SFTP server (Azure SFTP) seems...
Read more >npm:ssh2-sftp-client-mkdir-patch - Skypack.dev
the connection to server config pls see ssh2 client event. list of methods: all the methods will return a Promise;. List. Retrieves a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m having the same problem. If I use the .list() method, it gives me the list of files, but when I try to do a getFast, it says that the files do not exist.
This looks like it is ssh2-sftp-client, not ssh2?
At any rate, I suspect you have a bug in your code. In the then block of your promise chain, the call to client.fastGet() needs to be proceeded with a return statement. Without the return statement, your actually starting a whole new promise chain. In your original code, because the fastGet() call was in its own promise chain, the client.end() call was occurring before the fastGet() call was fulfilled. The client.end() call knows nothing about the fastGet() call as it is in a separate chain, so does not wait for it to be fulfilled. Removing the call to end allows the fastGet() call to be fulfilled, but now you have no way of knowing when the work is done and can close the connection. Add the return statement and the call to client.fastGet() becomes part of the promise chain, so client.end() will wait until it is fulfilled before ending the connection.
Change your code to