[Tutor] FTP Upload
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Jul 15 05:05:56 EDT 2020
Forwarding to list...
On 15/07/2020 09:53, John Weller wrote:
>> I don't see anything obviously wrong.
>>
>> Suggestions:
>>
>> 1) implement the callback and use it to display progress, just to check that the
>> number of blocks is what you'd expect for the filesize
>>
>> 2) pass the file object explicitly:
>>
>> def callback(block):
>> ....
>> print(....)
>>
>> cmd = "STOR %s" % filename
>> fd = open(...)
>> if fd:
>> ftp.storbinary((cmd, fd, callback)
>> fd.close()
>>
>> That shouldn't change anything, but my long standing approach to anything involving
>> files, especially binary ones, is to take full control of opening and closing!
>>
>> Otherwise I don't know what's up.
>
Thanks to all who responded. I've found the problem - but unfortunately
not the cause or the cure! The corrupt files have lost a handful of
bytes, not as a block, and the file is being terminated with x0A which
it shouldn't be. At least I know the syntax is correct, I'll try Alan's
approach next. It must be something in my environment so I'll look at
that as well.
John
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list