Automatically upload newly created files to an SFT

2019-02-21 01:04发布

An ASP.NET application (running on Windows server/IIS 7) has to transfer big size files uploaded by current user to an external SFTP server. Due to the file size the idea is to do this asynchronously.

The idea is that the ASP.NET application stores the uploaded file on a local directory of the Windows server. The current user can continue his work. A Windows service or a Quartz job (other tools(*)/ideas?) is now responsible to transfer the file to the external SFTP server.

(*) Are there existing tools that listen on changes of a Windows directory and then move the files on a SFTP server (incl. handling communication errors/retries)?

If there is no existing solution, do you have had similar requirements? What do we have to consider? Because the connection to the SFTP server is not very stable we need an optimized error handling with auto retry functionality.

1条回答
手持菜刀,她持情操
2楼-- · 2019-02-21 02:02

To watch for changes in a local directory in .NET, use the FileSystemWatcher class.


If you are looking for an out of the box solution, use the keepuptodate command in WinSCP scripting.

A simple example of WinSCP script (e.g. watch.txt):

open sftp://username:password@host/
keepuptodate c:\local_folder_to_watch /remote_folder
exit

Run the script like:

winscp.com /script=watch.txt

Though this works only, if the uploaded files are preserved in the remote folder.

(I'm the author of WinSCP)

查看更多
登录 后发表回答