[英]Watch FTP directory changes, then send to Rails app
I have a Rails app that has a strict requirement of receiving XML files via FTP on port 21. 我有一个Rails应用,该应用对在端口21上通过FTP接收XML文件有严格的要求。
I have FTP server set up to receive files (outside of the rails app), however I am having trouble finding solutions where I can have uploaded files be sent to my rails app so that they can be processed. 我已将FTP服务器设置为接收文件(在rails应用程序外部),但是我在寻找解决方案时遇到了麻烦,可以将已上传的文件发送到我的rails应用程序以便对其进行处理。
Is there a way to host an FTP server inside a rails app? 有没有办法在Rails应用程序中托管FTP服务器? Is there a way to watch arbitrary folders for changes and processes them? 有没有办法监视任意文件夹的更改并进行处理?
I am running Rails 4.2.5
, Ruby 2.3.1
on a Ubuntu 14.04
server. 我在Ubuntu 14.04
服务器上运行Rails 4.2.5
和Ruby 2.3.1
。
Regards, 问候,
The best solution is this: 最好的解决方案是这样的:
lib/xml_watcher.rb
for instance) that checks the directory for XML files, and processes them accordingly. 编写一个Ruby类(例如lib/xml_watcher.rb
),检查该目录中的XML文件,并进行相应的处理。 Ideally, if you're using Resque, all you need to do is schedule a new job for each file. 理想情况下,如果使用的是Resque,您要做的就是为每个文件安排一个新作业。 update: there are more advanced solutions that use IO events to instantly get notification of changed files. 更新:有更多高级解决方案使用IO事件来立即获取更改文件的通知。 This is nice, of course, but it also adds quite a lot of complexity. 当然,这很好,但同时也增加了很多复杂性。 I prefer the simple just works solution. 我更喜欢简单的正义解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.