[Haskell-cafe] upload file with ftp

Kees Bleijenberg K.Bleijenberg at lijbrandt.nl
Wed Jan 6 09:42:20 UTC 2021


Joachim, Brandon,

After investigating the source for the store command in  Network.FTP.Client (https://hackage.haskell.org/package/ftp-client-0.5.1.4/docs/Network-FTP-Client.html) I found that the stor command already sets the connection in passive mode. I tried my original code on Linux and everything works fine. So probably the problem is (as always) Windows.  

A few years ago I tried some Haskell ftp client libs. On Windows they all raised access violations as soon as I connected to a server. Now,  a few years later the Network library has improved (not sure) and I tried it again. Big improvements: Login, get a list of files, change directory works fine but stor does not.  So there is still no working FTP-client lib for Haskell (I think). 

I know FTP is not secure but it is easy to use. Almost everybody uses it for uploading files to a website. Writing code for uploading a file with http(s)in Haskell is a lot more work than ftp and I wonder whether the https stuff will work on Windows. And  with http(s) you have to write an extra server side program (php) to save the uploaded file, return error messages...
I just want a simple way to upload a generated file to my private website. 
Until now I upload a file by running a program within my Haskell program. That ftp-program sends a file with ftp to a server. The ftp-program is written in Delphi/Lazarus.

Thanks for your help.
Kees


-----Oorspronkelijk bericht-----
Van: Haskell-Cafe [mailto:haskell-cafe-bounces at haskell.org] Namens Joachim Durchholz
Verzonden: dinsdag 5 januari 2021 20:09
Aan: haskell-cafe at haskell.org
Onderwerp: Re: [Haskell-cafe] upload file with ftp

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
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.



More information about the Haskell-Cafe mailing list