[Haskell-cafe] upload file with ftp

Joachim Durchholz jo at durchholz.org
Tue Jan 5 19:08:34 UTC 2021


Am 05.01.21 um 16:54 schrieb Kees Bleijenberg:
> Unfortunately is ‘working in passive mode’ not so easy (at least not to 
> me). After login I send the ‘pasv’ command and I get back a IP address 
> and a port (I assume). Do I have to create a new connection with a 
> handle to this new port for the stor command?

Yes.

 >  I don’t know how to do that in network.ftp.client.

If network.ftp.client does not support that out of the box, you'll 
either have to find another library or add PASV support to it.

My knowledge of the FTP protocol is pretty rusty, but I believe you the 
model after PASV is that you continue using normal commands but the data 
transfers happen over the other connection.
I'd watch out for how the protocol marks the beginning and end of a data 
stream (it's not a single connection anymore so you lose the sequencing 
guarantees of TCP packets; I'd assume they either send a special packet 
on the data connection, or they transmit the file sizes via the normal 
channel).

However, I can't avoid wondering why anybody would want to use the FTP 
protocol at all. It's so unsafe, so bottleneck-endangered, the only 
reason to do that would be interfacing with existing FTP servers, and 
even these are being phased out in favor of HTTPS, with POST for uploads.
(I'm not questioning the validity of your use case, just wondering how 
such a use case can come up in today's world.)

Regards,
Jo


More information about the Haskell-Cafe mailing list