You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by MaGGE <ma...@magge.no> on 2008/01/06 18:50:52 UTC

Multipart/form - HttpClient 4

Hello,

I want to upload a file, or more specific a file and some parameters, in a
multipart/form.
I've not been able to find anything in the API docs or examples that show me
how (for HTTPClient-4).
I've read many places about MultipartRequestEntity - but thats not part of
HTTPCore/Client-4 as far as I can tell.

Is it possible to post multipart data using HTTPClient-4 ?

Thanks in advance!
Magnus
-- 
View this message in context: http://www.nabble.com/Multipart-form---HttpClient-4-tp14651373p14651373.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multipart/form - HttpClient 4

Posted by Roland Weber <os...@dubioso.net>.
MaGGE wrote:
> Hello,
> 
> I've opened JIRA issue https://issues.apache.org/jira/browse/HTTPCLIENT-728

Great, thanks!

> ...first time I've used JIRA so feel free to tell me if I did something
> wrong. :)

perfect job :-)

cheers,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multipart/form - HttpClient 4

Posted by MaGGE <ma...@magge.no>.
Hello,

I've opened JIRA issue https://issues.apache.org/jira/browse/HTTPCLIENT-728

...first time I've used JIRA so feel free to tell me if I did something
wrong. :)

Regards,
Magnus
-- 
View this message in context: http://www.nabble.com/Multipart-form---HttpClient-4-tp14651373p14659565.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multipart/form - HttpClient 4

Posted by Roland Weber <os...@dubioso.net>.
Hi Magnus,

thanks a lot for the feedback. Could you please
open an issue in JIRA and attach the code there?
If you check the "grant license for inclusion
in Apache" box, we can eventually put your code
somewhere into our contrib section.

https://issues.apache.org/jira/browse/HTTPCLIENT

thanks and cheers,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multipart/form - HttpClient 4

Posted by MaGGE <ma...@magge.no>.
A very simple wrapper is attached here. This one offcourse requires the
httpclient-3.1.jar in addition to httpclient-4 and httpcore.

There's an issue passing parameters from httpclient-4
HttpMethod.getProperties() (HttpParams from 4) to httpclient-3.1 and
MultipartRequestEntity's constructor which takes HttpMethodParams (from
3.1). I was thinking about doing an iteration of the parameters, but as far
as I could understand HttpMethodParams (from 3.1) is a static configuration,
thus it's alot of typing work and research to map httpclient-4s dynamic
properties to httpclient-3.1 configuration class. Furthermore I didn't find
any way of iterating the the parameters (at a glance). So, I gave that one
up. :)

In conclusion, MultipartRequestEntity is stuck with the default parameters.

http://www.nabble.com/file/p14656312/MultipartEntityWrapper.java
MultipartEntityWrapper.java 

It did it's job for me. That was pretty basic stuff, though. :)

Regards,
Magnus
-- 
View this message in context: http://www.nabble.com/Multipart-form---HttpClient-4-tp14651373p14656312.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multipart/form - HttpClient 4

Posted by MaGGE <ma...@magge.no>.
Ok, thanks for your advice.

If I make something half-decent - I'll post back here. :)

Regards,
Magnus
-- 
View this message in context: http://www.nabble.com/Multipart-form---HttpClient-4-tp14651373p14653623.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multipart/form - HttpClient 4

Posted by Roland Weber <os...@dubioso.net>.
Hello Magnus,

> I've not been able to find anything in the API docs or examples that show me
> how (for HTTPClient-4).
> I've read many places about MultipartRequestEntity - but thats not part of
> HTTPCore/Client-4 as far as I can tell.

That is correct. Multipart support is something we didn't port
to the 4.0 API:
http://hc.apache.org/status.html

> Is it possible to post multipart data using HTTPClient-4 ?

Yes, but you'll have to do some coding. There is no
MultipartRequestEntity that you can use out of the box.
One possibility is to re-use the multipart support of HttpClient 3.1:
http://marc.info/?l=httpclient-commons-dev&m=119708907028914&w=2
http://www.nabble.com/multipart-form-data-in-4.0-td14224819.html

If you don't want to depend on HttpClient 3, you can copy the
source and move it into a package of your own application.

hope this helps,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org