简体   繁体   English

Apache ftpserver uploadnotify

[英]Apache ftpserver uploadnotify

I'm using Apache ftpserver (Java). 我正在使用Apache ftpserver(Java)。 I need to have a nofication in my program when a file is uploaded through the ftp. 当通过ftp上传文件时,我需要在程序中使用nofication。 It seems to be possible but i can't find the way how to do it. 这似乎是可能的,但我找不到如何做到这一点的方式。

Any solutions out there? 有解决方案吗?

mina.apache.org/ftpserver mina.apache.org/ftpserver

You can get all notifications using ftplet. 您可以使用ftplet获取所有通知。 Check this out ... http://apilevel.wordpress.com/2011/05/12/ftplet-servlet-for-apache-ftpserver/ 看看这个...... http://apilevel.wordpress.com/2011/05/12/ftplet-servlet-for-apache-ftpserver/

I am assuming that, you have a desktop program, which is running on the ftpserver itself.. So as soon as any file is uploaded to the same ftpserver, your program must inform it...Right.!! 我假设你有一个桌面程序,它运行在ftpserver本身。所以只要任何文件上传到同一个ftpserver,你的程序必须通知它...对。!!

Lets see.... 让我们来看看....

  1. I am sure you have created a directory in the ftp server where the files will be uploaded. 我相信你已经在ftp服务器上创建了一个目录,用于上传文件。

  2. Make this program of your which is running on the same server to keep looking at the total nos of files in that folder/directory say for every 2mins or as per your requirement..Once the program notices that the nos of files have increased then i will raise an event of some kind in the program to inform u. 使你的这个程序在同一台服务器上运行,以便继续查看该文件夹/目录中的文件总数,每2分钟或根据您的要求说明。一旦程序注意到文件的数量已经增加,那么我会在节目中提出某种形式的事件来通知你。

How to do it... 怎么做...

  1. Create a Separate thread to keep looping the directory for any change in the nos of files. 创建一个单独的线程,以保持循环目录,以便对文件的任何更改进行更改。 Do Not make the Event Dispatcher thread to do it.. else your GUI will be Hanged. 不要让Event Dispatcher线程这样做.. 否则你的GUI将被绞死。

  2. Try the logic below.. 试试下面的逻辑..

     private static int max = 0; // i am assuming the folder is Empty. while(true) { File f = new File("path_of_files_on_ftp_server"); File[] farr = f.listFiles(); if ( farr.length > max ){ // There has been an upload...... // Raise the alarm here, by doing some event.... max = farr.length ; } else { continue; } 

    } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM