Once transferring a file to a server using ftplib, how do I determine the MD5 of that file to the one in my local server?
from ftplib import FTP
import hashlib
ftp = FTP('server')
ftp.login('username','password')
ftp.cwd('path_to_upload')
file_to_upload = open(file,'rb')
filename = os.path.basename(file)
ftp.storbinary('STOR ' + filename, file_to_upload)
local_file_hash = hashlib.md5(open(file, 'rb').read()).hexdigest()
# not sure how to achieve this
server_file_hash = hashlib.md5(open(filename, 'rb').read()).hexdigest()
if local_file_hash == server_file_hash:
print("Successful transfer")
else:
print("Failure transfer")