Calculate file checksum in FTP server using Apache FtpClient -


i using ftpclient of apache commons net upload videos ftp server. check if file has been transferred, want calculate checksum of remote file, unfortunately found there no related api use.

question is: whether there need calculate file checksum in ftp server?
if answer yes, how checksum in ftpclient?
if answer no, how ftpclient know if file has been , transferred?

with ftp, i'd recommend verify upload, if possible.

the problem there's no widespread standard api calculating checksum ftp.

there many proposals checksum calculation command ftp. none accepted yet.

the latest proposal is:
https://tools.ietf.org/html/draft-bryan-ftpext-hash-02

as consequence, different ftp servers support different checksum commands, different syntax. hash, xsha1, xsha256, xsha512, xmd5, md5, xcrc, name some. need check what, if any, ftp server supports.

you can test winscp. winscp supports mentioned commands. test checksum calculation function or checksum scripting command. if work, enable logging , check command , syntax winscp uses against server.

> 2015-04-28 09:19:16.558 xsha1 /test/file.dat < 2015-04-28 09:19:22.778 213 a98faefdb2c36ca352a2d9b01668aec6b641cf4b  

then execute command using apache commons net sendcommand method:

if (ftpreply.ispositivecompletion(ftpclient.sendcommand("xsha1", "filename")) {     string[] reply = ftpclient.getreplystrings(); } 

(i'm author of winscp)


if server not support of checksum commands, not have many options:

  • download file , check locally.
  • when using encryption (tls/ssl), chances of file being corrupted during transfer lower. receiving party (server in case) otherwise fail decrypt data. if sure file transfer completed (no decryption errors , size of uploaded file same size of original local file), can pretty sure uploaded file correct.