Calculate file checksum on FTP server using Apache FtpClient

I am using FtpClient from Apache Commons Net to upload videos to an FTP server. To check if the file was really transferred successfully, I want to calculate the checksum of the deleted file, but unfortunately, I found that there is no associated API that I could use.

My question is: Do I need to calculate the file checksum on the ftp server?
If so, how do I get the checksum in FtpClient?
If the answer is no, how does FtpClient know if the file was really successful and fully migrated?

+4
source share
3 answers

With FTP, I recommend checking the download, if possible.

The problem is that there is no widespread standard API for calculating checksum with FTP.

There are many suggestions for a checksum calculation command for FTP. No one has yet been accepted.

Last sentence:
https://tools.ietf.org/html/draft-bryan-ftpext-hash-02

As a result, different FTP servers support different checksum commands with different syntax. HASH, XSHA1, XSHA256, XSHA512, XMD5, MD5, XCRC, To name a few. You need to check if your FTP server supports it, if any.

WinSCP. WinSCP . checksum . , , WinSCP .

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

, Apache Commons Net sendCommand method:

if (FTPReply.isPositiveCompletion(ftpClient.sendCommand("XSHA1", "filename"))
{
    String[] reply = ftpClient.getReplyStrings();
}

( WinSCP)


- , :

  • .
  • (TLS/SSL) . ( ) . , , ( ), , .
+10

, . ftp- - , , , , MD5 CRC SFV . , uploads.sfv( , sfv). .

:

, @MartinPrikryl, .

0

, php, .

php (, check.php) , name_of_file.txt:

<? php
echo md5_file('name_of_file.txt');
php>

Then go to the page check.phpand you should get the md5 hash of your file.

Related questions:

0
source

Source: https://habr.com/ru/post/1585013/


All Articles