Anton - 2006-11-14

While making multipart/form-data post requests for file upload using byte[] buffer as file contents, that buffer gets corrupted for some reason. So the contents posted are far from what I wanted to be posed.

When I supply file path to curl in order to post that file - everything works fine.

Maybe I don't supply all needed parameters in AddSection() in case of buffer contents?

Here are 2 example form sections codes:

/**********  byte buffer gets corrupted somewhere in curl ***********/
                byte[] buffer = new byte[100];
                // populate buffer

                CURLFORMcode code = form.AddSection(CURLformoption.CURLFORM_COPYNAME, "inpFile1",
                    CURLformoption.CURLFORM_CONTENTTYPE, "application/octet-stream",
                    CURLformoption.CURLFORM_BUFFER, "File.bin",
                    CURLformoption.CURLFORM_BUFFERLENGTH, buffer.Length,
                    CURLformoption.CURLFORM_BUFFERPTR, buffer,
                    CURLformoption.CURLFORM_END);

/*********** wroks fine ************/
               
                CURLFORMcode code = form.AddSection(CURLformoption.CURLFORM_COPYNAME, "File.bin",
                    CURLformoption.CURLFORM_CONTENTTYPE, "application/octet-stream",
                    CURLformoption.CURLFORM_FILE, "c:\\File.bin",
                    CURLformoption.CURLFORM_FILENAME, "File.bin",
                    CURLformoption.CURLFORM_END);
               
Thanks
Anton