How to retrieve the file creation date from ftp

2019-09-08 15:34发布

I am using the library com.enterprisedt.net.ftp.FileTransferClient to download the files from ftp server.

I am trying to retrieve the ftp file creation date using the method FileTransferClient getModifiedTime(java.lang.String remoteFileName)

But receiving the below error:

com.enterprisedt.net.ftp.FTPException: 550 command MDTM is not available for 'AAAA.BBBB.CCCC.DDDDDD.EEEEEEEEEE(0)'

I tried using the command quote mdtm 'filename' from command line and same response.

Looked at both the links

  1. http://www.nsftools.com/tips/RawFTP.htm

  2. http://www.nsftools.com/tips/MSFTP.htm

But could not find any alternative or workaround for this..Any thoughts?

EDIT: Tried the command remotehelp and below is the response :

214-The server-FTP commands are: 214-ABOR,*ACCT,*ALLO, APPE, CDUP, CWD, DELE, FEAT, HELP, LANG, LIST, MDTM, MKD 214-MODE, NLST, NOOP, OPTS, PASS, PASV, PORT, PWD, QUIT, REIN, REST, RETR, RMD 214-RNFR, RNTO, SITE, SIZE, SMNT, SYST, STAT, STOR, STOU, STRU, TYPE, USER 214-ADAT, AUTH, CCC, PBSZ, PROT, EPSV, EPRT 214-The commands preceded by '' are not implemented

As per the response server should support the command MDTM..Am i doing anything wrong here?

标签: java ftp cmd
2条回答
倾城 Initia
2楼-- · 2019-09-08 16:05

As the response code said, the server you connected to does not support asking last-modified time of file.

MDTM (get last-modified time) is an extension, so it's optional for FTP server to implement it. Furthermore, there is no command for asking file creation time in any FTP-related RFC propose.

It's unlikely possible to do what you want by using FTP unless your FTP server has command for asking file creation time.

查看更多
Luminary・发光体
3楼-- · 2019-09-08 16:15

I think one could use

getRaw();

Javadoc tells:

getRaw()

public java.lang.String getRaw()

Returns:

Returns the raw server string.

So if you query the server with "LIST", you should get a List off all files including last modification time. The you have to parse out the modification time manually.

查看更多
登录 后发表回答