Search code examples
pythonajaxftptwistedbinary-data

Twisted Large File and String Transfer


I was wondering if twisted offers any type of protocol that would be necessary for handling large data types (Around 10MB). I was using the line receiver to do other communication; however, that obviously isn't going to happen (string limits are around 16,000 bytes, under line rec protocol)

I also have a web interface, so if you could shed some light on successfully transferring the file in response to an AJAX call, that would be awesome.


Solution

  • Twisted has support for several protocols that are suitable for transferring large strings. Netstrings, FTP, SFTP, and perhaps directly relevant to you, HTTP.

    AJAX is limited (by definition) to running over HTTP. There's nothing particular about using it with Twisted. Just send your data as the body of the response to one of your AJAX requests. You probably want to stream it incrementally to avoid using too much memory on your server, but otherwise there's nothing too special involved.