cURL / Mailing Lists / curl-library / Single Mail

curl-library

Upload with FTP: ReadFunction not called

From: AMBROSINI Marco <m.ambrosini_at_itcgr.net>
Date: Mon, 11 May 2009 16:26:24 +0200

Hi all,
I'm using curl-7.19.4 (win 32) - libcurlnet-1_3 and I'm trying to upload
a file to a FTP server.
I have no error, this is the debug log:
------------------------------------------------------------------------
-----
Trying 10.10.7.77...
connected
Connected to 10.10.7.77 (10.10.7.77) port 80
Proxy auth using NTLM with user 'DOMITC\u010101111'
Server auth using Basic with user 'ITCGROUP'
PUT ftp://ITCGROUP:doHw7yCSF3@83.169.75.86/in HTTP/1.1
Proxy-Authorization: NTLM TlRMTVNTUAABAAAAAgIAAAAAAAAgAAAAAAAAACAAAAA=
Authorization: Basic SVRDR1JPVVA6ZG9Idzd5Q1NGMw==
Host: 83.169.75.86:21
Pragma: no-cache
Accept: */*
Content-Length: 0
Expect: 100-continue

HTTP/1.1 100 Continue
Via: 1.1 ITCGR999VISA01
HTTP/1.1 200 OK

Via: 1.1 ITCGR999VISA01
Content-Type: text/html

<HTML>
<meta http-equiv="Content-Type" content="text-html; charset=UTF-8">
<HEAD>
<TITLE>FTP directory /in at 83.169.75.86. </TITLE>
</HEAD>
<BODY>
<H1>FTP directory /in at 83.169.75.86. </H1>
<HR>
<PRE>
                          &lt;DIR&gt; ..<BR></PRE>
<HR>
</BODY>
</HTML>

Connection #0 to host 10.10.7.77 left intact
------------------------------------------------------------------------
-----
And it seems all is working, but no file is found the ftp server and the
CURLOPT_READFUNCTION is not called (the breakpoint in the delegate is
not caught).
Here's my code:

++++++++++++++++++++++++++
            FileStream fs = null;
            Easy myEasy = null;
            try
            {
                fs = new FileStream(LocalFilePath, FileMode.Open,
FileAccess.Read, FileShare.Read);
                Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
                myEasy = new Easy();

                //read function
                Easy.ReadFunction rf = new
Easy.ReadFunction(OnReadData);
                myEasy.SetOpt(CURLoption.CURLOPT_READFUNCTION, rf);
                myEasy.SetOpt(CURLoption.CURLOPT_READDATA, fs);

                //debug function
                Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
                myEasy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);

                //other settings
                myEasy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);

                //proxy settings
                myEasy.SetOpt(CURLoption.CURLOPT_PROXY, strProxyServer);
                myEasy.SetOpt(CURLoption.CURLOPT_PROXYPORT,
strProxyPort);
                myEasy.SetOpt(CURLoption.CURLOPT_PROXYUSERPWD,
strProxyAccount);
                myEasy.SetOpt(CURLoption.CURLOPT_PROXYAUTH,
CURLhttpAuth.CURLAUTH_NTLM);

                //ftp server settings
                myEasy.SetOpt(CURLoption.CURLOPT_URL, strFTPServer);
                myEasy.SetOpt(CURLoption.CURLOPT_PORT, strFTPPort);
                myEasy.SetOpt(CURLoption.CURLOPT_USERPWD,
strFTPAccount);
                myEasy.SetOpt(CURLoption.CURLOPT_UPLOAD, true);
                myEasy.SetOpt(CURLoption.CURLOPT_INFILESIZE, fs.Length);

                //upload
                CURLcode result = myEasy.Perform();

        private static Int32 OnReadData(Byte[] buf, Int32 size, Int32
nmemb, Object extraData)
        {
--> breakpoint here not caught
            FileStream fs = (FileStream)extraData;
            return fs.Read(buf, 0, size * nmemb);
        }
++++++++++++++

Is there something wrong?

Thanks in advance,
Marco.
Received on 2009-05-11