curb icon indicating copy to clipboard operation
curb copied to clipboard

PostField.file does not work with PostField.content

Open antel opened this issue 15 years ago • 6 comments

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; boundary=----------------------------3865bbfb9820

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

Content-Length: 48735 Content-Type: multipart/form-data; boundary=---------------------------856536410836239252951956267

-----------------------------856536410836239252951956267

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

sdfadsf

-----------------------------856536410836239252951956267

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

dsafadfsdaf

asdfasdf

sdfsadf

-----------------------------856536410836239252951956267

Content-Disposition: form-data; name="file"; filename="youshouldnotreadthis.avi"

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 filenames?

antel avatar Nov 05 '10 04:11 antel

+ 1

acatighera avatar Dec 12 '11 20:12 acatighera

+1

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?

ghost avatar Jul 20 '15 16:07 ghost

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

taf2 avatar Jul 20 '15 17:07 taf2

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.

ghost avatar Jul 20 '15 17:07 ghost

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

taf2 avatar Jul 20 '15 18:07 taf2

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.

ghost avatar Jul 20 '15 18:07 ghost