atinux / node-ftps

FTP, FTPS and SFTP client for node.js, mainly a lftp wrapper.
MIT License
202 stars 57 forks source link

Error in path when uploading #75

Open zaghop opened 5 years ago

zaghop commented 5 years ago

I am attempting to transfer a file using SFTP on a windows machine. When the package attempts to send the file, it is using an incorrect path. I am passing in the full path location, but it is appending the following to the beginning of the path.

"/cygdrive/c/Scripts/file-mover/"

The script is located in C:/Scripts/file-mover. For example, if I pass in a filename of "C:/Temp/thisfile.txt" the error that I see is as follows:

{ error: 'put: /cygdrive/c/Scripts/file-mover/C:/Temp/thisfile.txt: No such file or directory\n', data: '' }

Is there a way to prevent this?

psuresh246 commented 4 years ago

Hi, Any update on this issue?

tirilo555 commented 1 year ago

I have the same problem

Akshatha1700 commented 2 months ago

ftps is used in unix environments, so its expecting the path to be in /cygdrive/c

Converting the windows path to unix path should be able to fix this issue.

const convertPathToUnix = (windowsPath) => { return windowsPath.replace(/\/g, '/').replace(/^([a-zA-Z]):/, '/cygdrive/$1'); };