python - ftp not transferring full file

Refresh

April 2019

Views

42 time

1

tl;dr, is there any reason that one file would fail to transfer completely over ftp, while every other file uploaded in the exact same way works fine?

Every week, I use python's ftplib to update my website – usually this consists of transferring around 30-31 files total - 4 that overwrite existing files, and the rest that are completely new. For basically all of these files, my code looks like:

myFile = open('[fileURL]', 'rb')
ftp.storbinary(cmd='STOR [fileURLonServer]', fp=myFile)
myFile.close()

This works completely fine for almost all of my files. Except for one: the top-level index.html file. This file is usually around 7.8-8.1 kb in size, depending on its contents from week to week. It seems to be the case that only the first 4096 bytes of the file are transferred to the server – I have to manually go in and upload the full version of the index every week. Why is it doing this, and how can I get it to stop? Is there some metadata in the file that could be causing the problem?

StackOverflow recommended me this question which doesn't solve my problem – I'm already using the rb mode for opening every file I'm trying to transfer, and each one except this one is working perfectly fine.

0 answers