Skip to content

PostField.file does not work with PostField.content #59

antel opened this Issue Nov 5, 2010 · 6 comments

4 participants

antel commented Nov 5, 2010

I've a big problem with upload forms, actually I can't do this
With $req.multipart_form_post = true :

$req.http_post(Curl::PostField.content("some", "content"),
Curl::PostField.file("desc", "descfile"))
it throws:
in `http_post': You must use PostFields only with
multipart form posts (Curl::Err::InvalidPostFieldError)

it works if I just do
$req.http_post(Curl::PostField.file("desc", "descfile"))

I've read in rdoc "no support for posting multipart forms from a
string is provided." but it doesn't seem related.

[works] one file upload:
Connection: Keep-Alive
Content-Length: 46316
Content-Type: multipart/form-data;

[doesn't works] [live http threads]
Connection: keep-alive

Content-Length: 48735
Content-Type: multipart/form-data;


Content-Disposition: form-data; name="subject"



Content-Disposition: form-data; name="message"





Content-Disposition: form-data; name="file";

Content-Type: application/x-bittorrent

NB: Content-disposition/name/filename/type are not shown in curb's
verbose output.
NB2: http_post with multipart doesn't accept multipart forms from a
string so how I upload two or more files with no prior knowloadge of


+ 1

gdonald commented Jul 20, 2015


I currently cannot upload a file that requires an API token for authentication. libcurl fully supports this functionality so I fail to understand why this bug is still outstanding after 5 years? Abandon-ware?

taf2 commented Jul 20, 2015

@gdonald i always welcome pull requests. It is probably not too hard for you to fix right?

gdonald commented Jul 20, 2015

I appreciate the offer but I'm just going to use Net::HTTP for this one part of my project. No idea on the difficulty, much like you I have not attempted a fix.

taf2 commented Jul 20, 2015

@gdonald do you have an example of it failing? I could always take a look if you have a failing example.

gdonald commented Jul 20, 2015

The example at the top of this page from 5 years ago seems apt. Curl::PostField.content and Curl::PostField.file cannot be used in the same request. Faulty/missing multipart support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.