Check if remote file exists before upload (wodSFTP / wodSFTP.NET / wodSFTPdll)
Hi,
I'm trying to verify if a file exists on the remote SFTP server before I upload, so I can decide if I want to overwrite or not.
I'm assuming I would do this in the loopEvent, as I am using PutFiles() to copy the files.
thanks
Check if remote file exists before upload
Hi.
I suggest you use GetAttributes method
http://www.weonlydo.com/SFTP/Help/wodSFTP-GetAttributes.html
for each file before the upload. If it returns an error - then file doesn't exist.
But you cannot use it in LoopItem event, since LoopItem fires while some other method is processing. You must wait for Done to complete in order to execute GetAttributes, so you should do it before GetFiles/PutFiles.
Kreso
Check if remote file exists before upload
I'm a little lost.
If I'm using putfiles() to copy a directory, how is calling Get Attributes on my instance of wodSFTP checking every file?
do you have an example of this you could provide?
Thanks
Check if remote file exists before upload
Hi.
You cannot use GetAttributes inside PutFiles, that's what I mentioned that is a problem. Rather, I would use ListDir to list directory contents, and then parse and put existing files in some local list.
Then in PutFiles check if there is a file in my local list, and that way determine if it exists on remote side or not.
There is no automated way to do this.
Kreso
Check if remote file exists before upload
I'm trying to use this process (in c#)
http://example.weonlydo.com/?did=Directory-listing-using-SFTP-protocol
Whenever it tries to do ListAttributes, I get a "Timeout occurred due to inactivity."
any suggestions?
Check if remote file exists before upload
should also note that I tried setting the timeout to zero, and then it just waits forever.
Check if remote file exists before upload
Hi.
ListAttributes is very similar to ListDir (same, under the hood). I don't see a reason it would fail. Does getting directory listing works using ListDir, or using some other SFTP client (such as FileZilla)?
Kreso
Check if remote file exists before upload
well, I found that it doesn't seem to like ListAttributes being in the connectedEvent. Once I removed the event and just called ListAtributes before the PutFiles method, I was able to get results (while still using AttributesDataEvent.
Check if remote file exists before upload
Are you using Blocking = 1 ? If so, don't use any methods inside events, since everything will block (and eventually Timeout).
Kreso