curl-library
RE: Need urgend help to use libcurl to transfer zip file via FTP
Date: Wed, 23 Jun 2010 15:20:50 +0200
Hi all,
I need help urgently.
I wanted to transfer zip file using libcurl via FTP from UNIX to
VMS. Although I told libcurl to use binary mode, it seems that it did
not work, because the zip file was modified after the transfer. Some
carriage returns in the zip file were converted to line feeds, so that
the unzip tool could not unzip the file.
I did the transfer in the following way:
...
curl_easy_setopt( curl, CURLOPT_CUSTOMREQUEST,"TYPE I" );
res_g = curl_easy_perform( curl );
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST ,"RETR
test_zip.yyy");
res = curl_easy_perform(curl);
...
I tried a lot of options to be set, such as
CURLOPT_PROXY_TRANSFER_MODE, CURLOPT_CRLF ... and so on. But without
success.
Can anyone help me? Or can anyone give me some suggestions or
hints?
Thank you very much!
Hanmei
Hi,
Do you really need a custom request here?
You can download a binary file like this (at least this works in my
case: Linux->Linux):
FILE *fdTargetBinFile;
/* open your target bin file pointer "wb" */
curl_easy_setopt( curl, CURLOPT_WRITEDATA, fdTargetBinFile);
curl_easy_setopt( curl, CURLOPT_URL, szUrlToRemoteFile);
...
curl_easy_perform(curl);
/* close your target bin file pointer */
I hope this is some help to you.
Cheers,
Lutz
Hi Lutz,
I tried your way. It worked wonderfully. In my own solution I set the
CURLOPT_URL to a directory and then used custom requests to execute FTP
commands like NLST, RETR etc. It worked in the case of ASCII files but
not binary files. Now my program works with your help in the two cases.
Thanks a lot once more.
Cheers,
Hanmei
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-06-23