问题描述
ASP.NET应用程序(在Windows服务器/ IIS 7上运行)必须将当前用户上传的大文件传输到外部SFTP服务器。由于文件大小,我们的想法是异步执行此操作。
想法是ASP.NET应用程序将上载的文件存储在Windows服务器的本地目录中。当前用户可以继续他的工作。 Windows服务或Quartz作业(其他工具(*)/ ideas?)现在负责将文件传输到外部SFTP服务器。
(*)是否有现有的工具可以监听Windows目录的更改,然后在SFTP服务器上移动文件(包括处理通信错误/重试)? / p>
如果没有现有的解决方案,您是否有类似的要求?我们需要考虑什么?由于与SFTP服务器的连接不是很稳定,我们需要使用自动重试功能优化错误处理。
要注意在.NET中的本地目录中进行更改,使用
。
如果你是寻找开箱即用的解决方案,使用中的>命令。
WinSCP脚本的一个简单示例(例如 watch.txt
):
open sftp://用户名:password @ host /
keepuptodate c:\ local_folder_to_watch / remote_folder
退出
运行如下脚本:
winscp。 com /script=watch.txt
虽然这只适用,但如果上传的文件保存在遥控器中文件夹。
(我是WinSCP的作者)
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.
To watch for changes in a local directory in .NET, usethe 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)
这篇关于自动将新创建的文件上载到SFTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!