[Twisted-Python] FTPClient storeFile help.

Oisin Mulvihill oisin at enginesofcreation.ie
Fri Oct 3 06:18:28 EDT 2003


Glyph Lefkowitz wrote:

> Oisin Mulvihill wrote:
>> I confess I really don't know how to handle the two deferred
>> object that get returned by storeFile. I just add callback/
>> errorback for each, this could be the problem.
> If you want to wait for both, use twisted.internet.defer.DeferredList.
Why are there two deferred objects returned by storeFile? The documentation

storeFile (self ,path ):

    Store a file at the given path.

    This method issues the 'STOR' FTP command.


    A tuple of two Deferreds:
    * Deferred IFinishableConsumer . You must call the finish method on the
        IFinishableConsumer when the file is completely transferred.

    * Deferred list of  control-connection responses.

This really doesn't help me much. I get the impression that storeFile
isn't sending the contents of file, because its waiting for me to stream
the file contents somehow. Maybe via IFinishableConsumer?

In my current program, using ftplib, I do the following to upload a file:

    ftp.storbinary('STOR %s' % (filename), fp)

This has the filename and a file descriptor passed to it. Is something 
like this
needed with storeFile?

Please can someone give me an answer to this, as looking at the code for
twisted.protocols.ftp isn't helping much either. This function seems to be
a mystery to me and I want to understand how to use it properly.



>> Can anyone enlighten me as to what I'm doing wrong. I would
>> really like to use proper async behavior for doing the uploads,
>> instead of using threads + ftplib.
> The FTP implementation in Twisted is sub-optimal (although that's 
> mostly the server).  If you don't get any satisfactory responses I 
> recommend assigning a bug to spiv in the tracker :).

Oisin Mulvihill
Engines Of Creation

Email: oisin at enginesofcreation.ie
Work: +353 1 6791602
Mobile: +353 868191540

More information about the Twisted-Python mailing list