I use python ftplib to upload binary file to remote ftp server, but it always transfers less than its actually size.
ps: local env is windows, remote server is linux.
I use:
'ftp.storbinary('STOR %s' % filename,open(filename,'rb'))'
I think python’s api read() is not work properly, it recognizes some special character as EOF which actually not.
How can I upload a binary file without lost bytes?
Several hard tests have been made before I understood why. First, this is not a bug in python. Because the file to be transferred hasn’t been flushed to disk from memory,for this:
After doing this, file handler is not closed explicitly,
retrbinarydoesn’t close it, so storing it immediately will lose some bytes which are in memory.So if we close the file handler explicitly after storing it, like this:
then we got all bytes, for more detail, see: ‘http://blog.csdn.net/hongchangfirst‘