开发者

Grails handling FTP dump

开发者 https://www.devze.com 2023-03-13 10:19 出处:网络
I have a site where users are uploading files with a form and it posts and its great, but one customer insists on using FTP instead.I have determined three options for handling this, and I was wonderi

I have a site where users are uploading files with a form and it posts and its great, but one customer insists on using FTP instead. I have determined three options for handling this, and I was wondering if anyone has any insight on which is best (or if there is a different overflow I should be asking this on), or if there is a fourth better option.

Solution 1: Learn Linux. I could probably write a cron job that looks in the directory to which they're uploading every 5 minutes and then post the files it finds into my site.

Solution 2: Create a timer driven service in grails that looks in the directory every 5 minutes. This is what I'm going to start trying.

Solution 3: This would be hard, but I'm sure it would be possible to have grails pretend to be a FTP server开发者_运维百科 allowing the ftp dump to be like a post. I have no idea where to start this solution, so unless there is a plugin this isn't happening.


You can use the Grails Quartz plug-in to schedule a task, if you want to pursue option two in your list.


I would go for option 2 and use the Quartz plugin as suggested (rather than cron). Handling files in Groovy are simple and you have lots of examples such as this from mrhaki.

If you think the processing of files will have more complex requirements you could try out something like Apache Camel with this example from the same mrhaki. Though I believe Spring has its own framework that may be a better fit, you'll have to investigate that yourself if you go down that road.


Grails is a web framework so options 2 and 3 are less than ideal. If having the file that is ftped immediately available in your application option 1 is the quickest and simplest solution of the 3 I think.

Another option is to find an open source FTP server (there are several) and modify it to import the document into your system directly. This will allow your client to use the protocol they prefer (FTP) and still get the file into your application in real time.

Still another option is to provide an FTP like client that will use your grails application as the server. Whether this is suitable or not depends on why the client insists on using FTP which you should determine up front to make sure your solution works for them.

0

精彩评论

暂无评论...
验证码 换一张
取 消