cURL / Mailing Lists / curl-library / Single Mail

curl-library

Posting large files

From: Gross, Tim (Utility Computing Architect) <tim.gross_at_hp.com>
Date: Fri, 25 Sep 2009 00:31:57 +0000

Hello,
Here is some abbreviated code from an http post that I am performing.

    static const char buf[] = "FILE_SIZE=3130&FILE_NAME=myfile.txt&TRANS_ID=123\nSome additional content";

    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buf);
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    curl_easy_perform(curl);

This works, and on the server side, I end up with a file on disk named "myfile.txt" that contains "Some additional content". This is how the CGI program operates, as expected. However, what I really want to do is to transfer the contents of a large file (could be greater than 100Kbytes) instead of the text "Some additional content". I could always read the file contents into buf[] and transfer it in all in one operation. But I think that could lead to performance issues, because the file to transfer can be arbitrarily large. I know the server is expecting the payload to be in the same form as buf[] above. What I would like to do is transfer it in chunks. First send the "FILE_SIZE=3130&FILE_NAME=myfile.txt&TRANS_ID=123\n" portion, then send the file contents split up into smaller pieces. I am fairly certain that the server is expecting an HTTP Post.

This is probably a very simple thing to do, but I haven't found a way to get it working.

I am working on RHEL 5.1, libcurl version 7.19.

Does anybody have any suggestions on how to do this?
Thanks,
Tim.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-09-25