theophilusx/ssh2-sftp-client

Not able to transfer a file from Azure Blob to FTP location

rezarezash opened this issue · 3 comments

Hi, I am using "fastPut" to transfer a publicly available blob file from Azure blob storage to my FTP location but I get the following error:

Error: fastPut: Bad path: https://acount.blob.core.windows.net/htmlfiles/test.html: ENOENT: no such file or directory, access

@theophilusx Thanks alot. It worked.

This error looks like your trying to pass a URL as the file path specification. This is not supported. The file path has to be either a local path or a remote sftp path (note SFTP and not FTP as well). If you want to transfer the file from a web server you will need to first retrieve the remote file using an http client library and then pass that data to the sftp method. The likely best way to do this would be to use an http client module which returns a readStream which you could then pass to the ssh put() method. Note that for this you cannot use fastPut as fastPut only accepts string arguments which specify a file path whereas put() and get() accept streams, buffers or string path designators. The benefit of using the stream is that you won't have to first download the data via http, store it somewhere and then pass the location of that temporary storage file to put(). Provided the http client module you use returns a standard node readable stream object, you can just pass that into put() as the source and the underlying node stream piping support will take care of the rest.

@theophilusx Thanks alot. It worked.