I am trying to use a PeopleCode app engine to delete files from a remote server. GetAttachment would work except that I want to loop through a the whole directory on the server and match files like march.csv.
Also, I am needing to do this by date range. *.csv between date 1 and date 2.
Get attachment seems to require that you know the file name and individually delete the files. So pattern pattern matching will not work.
I can get the list and check dates using java objects:
Local JavaObject &joFile = CreateJavaObject("java.io.File", SFO_DEL_FTP_AET.FTPDIRECTORY); Local JavaObject &joFileList; Local JavaObject &reflectArray = GetJavaClass("java.lang.reflect.Array"); Local JavaObject &dttm_format = CreateJavaObject("java.text.SimpleDateFormat", "yyyy-MM-dd");
but I can only use that with local servers.
Is there a way to actually connect to the server, then use the java objects?
Thanks, JPS
You could use Apache Commons NET library for this. One of the packages is intended for FTP/FTPS access.
Once you get the file list, you could retrieve the name from the
FTPFile
object.In order to delete a file, you could use FTPClient's
deleteFile
method.You can download the NET library here