cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Fwd: Facing an issue while doing FTP download for large file size:

From: lakshmi <lakshmi_at_dikshatech.com>
Date: Fri, 18 Mar 2011 16:17:51 +0530

Hi,

Alex: As per your suggestions, i tried downloading file with curl
command line tool and it worked !
curl generated a source code which is shown below:-

Now, the problem is there are list of curl API's in the below source
code .. confused which to include and which not to in my piece of program !
But i tried to include an API called "curl_easy_setopt(hnd,
CURLOPT_FTP_FILEMETHOD, 0)", which downloads only 4KB from a given 56KB
file !
I even mentioned the number of bytes as third parameter to the API which
din't work!

Please suggest me as to which API's will be related for download of files??

/********* Sample code generated by the curl command line tool **********
 * Lines with [REMARK] below might need to be modified to make this code
 * usable. Add error code checking where appropriate.
 * Compile this with a suitable header include path. Then link with
 * libcurl.
 * If you use any *_LARGE options, make sure your compiler figure
 * out the correct size for the curl_off_t variable.
 * Read the details for all curl_easy_setopt() options online on:
 * http://curlm.haxx.se/libcurl/c/curl_easy_setopt.html
 ************************************************************************/
#define _FILE_OFFSET_BITS 64 /* for pre libcurl 7.19.0 curl_off_t magic */
#include <curl/curl.h>

int main(int argc, char *argv[])
{
  CURLcode ret;
  CURL *hnd = curl_easy_init();
  /* curl_easy_setopt(hnd, CURLOPT_WRITEDATA, 0xbf8a3888); [REMARK] */
  /* curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, 0x804db40); [REMARK] */
  /* curl_easy_setopt(hnd, CURLOPT_READDATA, 0xbf8a38c8); [REMARK] */
  /* curl_easy_setopt(hnd, CURLOPT_READFUNCTION, 0x804dad0); [REMARK] */
  /* curl_easy_setopt(hnd, CURLOPT_SEEKDATA, 0xbf8a38c8); [REMARK] */
  /* curl_easy_setopt(hnd, CURLOPT_SEEKFUNCTION, 0x804da90); [REMARK] */
  curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, -1);
  curl_easy_setopt(hnd, CURLOPT_URL,
"ftp://sitansu.sekhar:praya123@172.16.1.6/ProcExec.tar.gz");
  curl_easy_setopt(hnd, CURLOPT_PROXY, NULL);
  curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1);
  curl_easy_setopt(hnd, CURLOPT_HEADER, 0);
  curl_easy_setopt(hnd, CURLOPT_FAILONERROR, 0);
  curl_easy_setopt(hnd, CURLOPT_UPLOAD, 0);
  curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 0);
  curl_easy_setopt(hnd, CURLOPT_APPEND, 0);
  curl_easy_setopt(hnd, CURLOPT_NETRC, 0);
  curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 0);
  curl_easy_setopt(hnd, CURLOPT_UNRESTRICTED_AUTH, 0);
  curl_easy_setopt(hnd, CURLOPT_TRANSFERTEXT, 0);
  curl_easy_setopt(hnd, CURLOPT_USERPWD, NULL);
  curl_easy_setopt(hnd, CURLOPT_PROXYUSERPWD, NULL);
  curl_easy_setopt(hnd, CURLOPT_NOPROXY, NULL);
  curl_easy_setopt(hnd, CURLOPT_RANGE, NULL);
  /* curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, 0xbf8a370c); [REMARK] */
  curl_easy_setopt(hnd, CURLOPT_TIMEOUT, 0);
  curl_easy_setopt(hnd, CURLOPT_REFERER, NULL);
  curl_easy_setopt(hnd, CURLOPT_AUTOREFERER, 0);
  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.20.1
(i686-pc-linux-gnu) libcurl/7.20.1 OpenSSL/1.0.0a zlib/1.2.3
libidn/0.6.5 libssh2/1.2.5");
  curl_easy_setopt(hnd, CURLOPT_FTPPORT, NULL);
  curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_LIMIT, 0);
  curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_TIME, 0);
  curl_easy_setopt(hnd, CURLOPT_MAX_SEND_SPEED_LARGE, 0);
  curl_easy_setopt(hnd, CURLOPT_MAX_RECV_SPEED_LARGE, 0);
  curl_easy_setopt(hnd, CURLOPT_RESUME_FROM_LARGE, 0);
  curl_easy_setopt(hnd, CURLOPT_COOKIE, NULL);
  curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSLCERT, NULL);
curl_easy_setopt(hnd, CURLOPT_SSLCERTTYPE, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSLKEY, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSLKEYTYPE, NULL);
  curl_easy_setopt(hnd, CURLOPT_KEYPASSWD, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSH_PRIVATE_KEYFILE, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSH_PUBLIC_KEYFILE, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 2);
  curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS,
"/home/lakshmi/.ssh/known_hosts");
  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50);
  curl_easy_setopt(hnd, CURLOPT_CRLF, 0);
  curl_easy_setopt(hnd, CURLOPT_QUOTE, NULL);
  curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, NULL);
  curl_easy_setopt(hnd, CURLOPT_PREQUOTE, NULL);
  curl_easy_setopt(hnd, CURLOPT_HEADERDATA, NULL);
  curl_easy_setopt(hnd, CURLOPT_COOKIEFILE, NULL);
  curl_easy_setopt(hnd, CURLOPT_COOKIESESSION, 0);
  curl_easy_setopt(hnd, CURLOPT_SSLVERSION, 0);
  curl_easy_setopt(hnd, CURLOPT_TIMECONDITION, 0);
  curl_easy_setopt(hnd, CURLOPT_TIMEVALUE, 0);
  curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, NULL);
  /* curl_easy_setopt(hnd, CURLOPT_STDERR, 0x45e560); [REMARK] */
  curl_easy_setopt(hnd, CURLOPT_HTTPPROXYTUNNEL, 0);
  curl_easy_setopt(hnd, CURLOPT_INTERFACE, NULL);
  curl_easy_setopt(hnd, CURLOPT_KRBLEVEL, NULL);
  curl_easy_setopt(hnd, CURLOPT_TELNETOPTIONS, NULL);
  curl_easy_setopt(hnd, CURLOPT_RANDOM_FILE, NULL);
  curl_easy_setopt(hnd, CURLOPT_EGDSOCKET, NULL);
  curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 0);
  curl_easy_setopt(hnd, CURLOPT_ENCODING, NULL);
  curl_easy_setopt(hnd, CURLOPT_FTP_CREATE_MISSING_DIRS, 0);
  curl_easy_setopt(hnd, CURLOPT_IPRESOLVE, 0);
  curl_easy_setopt(hnd, CURLOPT_FTP_ACCOUNT, NULL);
  curl_easy_setopt(hnd, CURLOPT_IGNORE_CONTENT_LENGTH, 0);
  curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 0);
  curl_easy_setopt(hnd, CURLOPT_FTP_FILEMETHOD, 0);
  curl_easy_setopt(hnd, CURLOPT_FTP_ALTERNATIVE_TO_USER, NULL);
  curl_easy_setopt(hnd, CURLOPT_SSL_SESSIONID_CACHE, 1);
  /* curl_easy_setopt(hnd, CURLOPT_SOCKOPTFUNCTION, 0x804d350); [REMARK] */
  /* curl_easy_setopt(hnd, CURLOPT_SOCKOPTDATA, 0xbf8a3440); [REMARK] */
  curl_easy_setopt(hnd, CURLOPT_POSTREDIR, 0);
  ret = curl_easy_perform(hnd);
  curl_easy_cleanup(hnd);
  return (int)ret;
}
/**** End of sample code ****/

Arunkumar Manickam wrote:
> error 530 is for invalid username and password.
> be sure to give the username and password for the ftp server account .
>
>
> On Fri, Mar 18, 2011 at 12:05 PM, lakshmi <lakshmi_at_dikshatech.com
> <mailto:lakshmi_at_dikshatech.com>> wrote:
>
> When i try to download the file with curl command line tool, i get
> the following error when i use "curl -O -u --user=name:password
> ftp://machine.domain/full path to file" !
>
> The error is: curl: (67) Access denied: 530
>
>
> Arunkumar Manickam wrote:
>
> [off the list] first see if your download succeeds with curl
> command line tool. to eliminate the possibility of some server
> misconfiguration.
>
> ---------- Forwarded message ----------
> From: *Alex Bligh* <alex_at_alex.org.uk <mailto:alex_at_alex.org.uk>
> <mailto:alex_at_alex.org.uk <mailto:alex_at_alex.org.uk>>>
> Date: Thu, Mar 17, 2011 at 7:33 PM
> Subject: Re: Facing an issue while doing FTP download for
> large file size:
> To: lakshmi <lakshmi_at_dikshatech.com
> <mailto:lakshmi_at_dikshatech.com> <mailto:lakshmi_at_dikshatech.com
> <mailto:lakshmi_at_dikshatech.com>>>, the curl tool
> <curl-users_at_cool.haxx.se <mailto:curl-users_at_cool.haxx.se>
> <mailto:curl-users_at_cool.haxx.se <mailto:curl-users_at_cool.haxx.se>>>
>
>
> Lakshmi,
>
>
> --On 17 March 2011 18:55:24 +0530 lakshmi
> <lakshmi_at_dikshatech.com <mailto:lakshmi_at_dikshatech.com>
> <mailto:lakshmi_at_dikshatech.com
> <mailto:lakshmi_at_dikshatech.com>>> wrote:
>
> Actually i have even tried passing the exact file size to
> curl API but
> din't work !
>
>
> I would suggest you just omit the line.
>
> Also, can I suggest you look at the "--libcurl" option of the
> curl command line tool.
>
> --libcurl <file>
> Append this option to any ordinary curl
> command line, and
> you will get a libcurl-using source code written to
> the
> file that does the equivalent of what your command-line
> operation
> does!
>
>
> curl will write the source code for you.
>
> Alex
>
>
>
>
> Alex Bligh wrote:
>
>
>
> --On 17 March 2011 18:10:53 +0530 lakshmi
> <lakshmi_at_dikshatech.com <mailto:lakshmi_at_dikshatech.com>
> <mailto:lakshmi_at_dikshatech.com
> <mailto:lakshmi_at_dikshatech.com>>> wrote:
>
> I am trying to do FTP download using the curl API
> "CURLOPT_MAXFILESIZE"
> for a file which is of 400MB !
>
>
> The curl library list is here:
> http://cool.haxx.se/mailman/listinfo/curl-library
>
> Curl API is:
> curl_easy_setopt(curlHandle_m,
> CURLOPT_MAXFILESIZE, 3L);
>
> The following error occurs and the file doesn't get
> downloaded: "63
> Maximum file size exceeded"
>
>
>
> >From the man page:
>
>
> CURLOPT_MAXFILESIZE
>
> Pass a long as parameter. This allows you to
> specify the
> maximum size
> (in
> bytes) of a file to download. If the file requested is
> larger than this
> value, the transfer will not start and
> CURLE_FILESIZE_EXCEEDED will be
> returned.
>
> The file size is not always known prior to
> download, and
> for such files
> this option has no effect even if the file transfer
> ends
> up being larger
> than this given limit. This concerns both FTP and HTTP
> transfers.
>
>
> You are setting the maximum file size to 3 bytes. Is that
> really what
> you intended? 400MB > 3 bytes.
>
>
>
>
>
>
> --
> Alex Bligh
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
>
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-18