curl-library
Sending Large files via CURLOPT_HTTPPOST ?
Date: Tue, 25 Jun 2002 18:16:54 -0700
Hi all. Sorry if this is a newbie problem but:
I am using Curllib (7.9.7 on Win32 from C++) to post binary files via
HTTP. It works great for any file up to a certain size (haven't spent
the time to narrow it down exactly). But a file of 1,691,648 posted
fine, and a file of 3,059,712 bytes fails with error code 55
(CURLE_SEND_ERROR). I know that my serverside code can take the large
files, so I assume this is some sort of buffer overrun. I am using the
POSTEDFILESIZE option, but it doesn't make any difference.
Can anyone help me? Thank you very much and please excuse the newbie
question. My code is below:
Jeff
int HttpPostFile(const CString &LocalFile, long FileSize){
int RetVal = 0;
CURL* CurlHandle = curl_easy_init(); //init curl functions and return
handle
struct HttpPost* post = NULL;
struct HttpPost* last = NULL;
/* Add simple file section */
curl_formadd(&post, &last, CURLFORM_COPYNAME, "MyFile",
CURLFORM_FILE, LocalFile, CURLFORM_END);
/* Add file/contenttype section */
curl_formadd(&post, &last, CURLFORM_COPYNAME, "MyFile",
CURLFORM_FILE, LocalFile,
CURLFORM_CONTENTTYPE, "application/binary",
CURLFORM_END);
/* Set the form info */
curl_easy_setopt(CurlHandle, CURLOPT_POSTFIELDSIZE, FileSize);
curl_easy_setopt(CurlHandle, CURLOPT_HTTPPOST, post);
curl_easy_setopt(CurlHandle, CURLOPT_URL, m_HttpFilePostUrl);
RetVal = curl_easy_perform(CurlHandle); //perform the post
curl_formfree(post); //free memory for form
curl_easy_cleanup(CurlHandle); //free curl session
return RetVal;
}
-------------------------------------------------------
This sf.net email is sponsored by: Jabber Inc.
Don't miss the IM event of the season | Special offer for OSDN members!
JabConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn
Received on 2002-06-26