cURL / Mailing Lists / curl-library / Single Mail



From: Ramprakash Jelari thinakaran <>
Date: Tue, 29 Jan 2008 20:08:10 +0530

Hi all,

Could be nice if any one can clarify the following doubts.

I am trying to do the HTTP POST [only post ] of a file which can vary the
size from 10 MB to 5 GB and have
written the following reading call back in c++.

READSIZE is 1024*1024

static size_t dataRead_Callback(void *ptr, size_t size, size_t nmemb, void
   if(size*nmemb < 1)
   return 0;

   std::ifstream * is= static_cast<std::ifstream*>(input);
   is->read((char *)ptr,READ_SIZE);
   string s((char*)ptr);
   cout<<"Sending..."<<s<<" size is "<<is->gcount()<<endl;
   if( is->eof()) { cout<<endl<<"Reaching eof "<<endl;
   return -1;
   return is->gcount();


from main function, i have called the following

curl_easy_setopt(handler, CURLOPT_READFUNCTION, dataRead_Callback);

curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE_LARGE, fileSize);

curl_easy_setopt(handler, CURLOPT_READDATA, &fobj);

where fobj is the ifstream object.

1. Would like to know what the size and nmemb exactly mean in

2. Do we need to allocate the memory explictly for 'ptr' in
dataRead_Callback ()?

Received on 2008-01-29