You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Digital Monkey <al...@digitalmonkey.co.uk> on 2002/05/30 11:43:53 UTC
WebRequest / multipart/form-data
I may have a tidy solution to the multipart/form-data problem posed by
Gunnar Ole Skogen, using the HTTPClient classes from Ronald Tschalär
(http://www.innovation.ch/java/HTTPClient/) a block of code such as
below may be used to construct a multipart test example.
import HTTPClient.Codecs;
import HTTPClient.NVPair;
.
.
.
NVPair[] hdrs = new NVPair[1];
public void beginUpload(WebRequest theRequest)
{
NVPair[] opts = { new NVPair("option", "myoption") };
NVPair[] file = { new NVPair("comment", "/home/alan/src.zip") };
try {
byte[] data = Codecs.mpFormDataEncode(opts, file, hdrs);
InputStream i = new ByteArrayInputStream(data);
theRequest.setUserData(i);
theRequest.setContentType(hdrs[0].getValue());
i.close();
} catch (IOException e) {
System.out.println("Error Building Multipart");
}
}
If this helps anyone, please let me know - I would be happy to write up
a more detailed explanation for inclusion in the docs
Alan Perfect
DigitalMonkey
www.digitalmonkey.co.uk
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: WebRequest / multipart/form-data
Posted by Vincent Massol <vm...@octo.com>.
Hi Alan,
Thanks! I'm putting this in the FAQ.
As for the longer term, I'm very keen on integration such a feature
within Cactus but we have already standardized on using Jakarta Commons
HttpClient. There is also the Jakarta Commons Codec project that we
could use. If someone could find a solution using these frameworks, that
would be great, and we could include it in Cactus 1.4
Thanks
-Vincent
> -----Original Message-----
> From: Digital Monkey [mailto:alan@digitalmonkey.co.uk]
> Sent: 30 May 2002 10:44
> To: cactus-user@jakarta.apache.org
> Subject: WebRequest / multipart/form-data
>
> I may have a tidy solution to the multipart/form-data problem posed by
> Gunnar Ole Skogen, using the HTTPClient classes from Ronald Tschalär
> (http://www.innovation.ch/java/HTTPClient/) a block of code such as
> below may be used to construct a multipart test example.
>
> import HTTPClient.Codecs;
> import HTTPClient.NVPair;
> .
> .
> .
> NVPair[] hdrs = new NVPair[1];
>
> public void beginUpload(WebRequest theRequest)
> {
> NVPair[] opts = { new NVPair("option", "myoption") };
> NVPair[] file = { new NVPair("comment", "/home/alan/src.zip") };
> try {
> byte[] data = Codecs.mpFormDataEncode(opts, file, hdrs);
> InputStream i = new ByteArrayInputStream(data);
> theRequest.setUserData(i);
> theRequest.setContentType(hdrs[0].getValue());
> i.close();
> } catch (IOException e) {
> System.out.println("Error Building Multipart");
> }
> }
>
> If this helps anyone, please let me know - I would be happy to write
up
> a more detailed explanation for inclusion in the docs
>
> Alan Perfect
> DigitalMonkey
> www.digitalmonkey.co.uk
>
>
> --
> To unsubscribe, e-mail: <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>