[ftputil] problem uploading files to ftp server (SOLVED)
Stefan Schwarzer
sschwarzer at sschwarzer.net
Wed Feb 7 02:03:50 CET 2007
Hello,
the problem came from an inappropriate mode value for the upload
method. The parameters for upload are
local_file_name, remote_file_name, mode="a"
That is, the mode value is optional, but it defaults to ASCII
transfer though most transfers are actually better done in
binary mode (mode="b"). The ASCII default is because of
similarity between normal Python files and ftputil's interface.
As you may remember, it was and is one of ftputil's design goals
to be very similar to Python's filesystem interface (files,
modules os, os.path and shutil) to make ftputil easy to learn.
In most cases, however, binary mode is the best choice for the
upload and download methods.
On the other hand, the sizes of wcc's binary files when
transferred in ASCII mode should have been either rather small
(source file truncated at first ^Z) or similar in size (just
0x0a converted to 0x0d 0x0a sequences). On my Unix system, the
latter is the case. On wcc's Windows system, the source file
is actually truncated at the first ^Z, but the target file
sizes are much larger as one would expect because of this
truncation. We didn't find a reason for this even after a lot
of experiments; we only found that using binary mode fixed the
problem in the first place.
Best wishes
Stefan
More information about the ftputil
mailing list