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 Nir Dweck <ni...@vasco-de.com> on 2013/04/09 15:37:52 UTC

receiving a multipart entity at a http server

Hi,
I am trying to receive a multipart entity at my http server and am having
trouble to parse it.
The request includes a header:
Content-Type: multipart/form-data;
boundary=-------------------------acebdf13572468
my code does the following:
BasicHttpEntity entity = (BasicHttpEntity)entityReq.getEntity();
long len = entity.getContentLength();
byte[] data = new byte[(int)len];
int read = entity.getContent().read(data, 0, (int)len);

and when I look at the the read bytes they hold:
includes a BasicHttpEntity and when I read it I see the content is:
---------------------------acebdf13572468
Content-Disposition: form-data; name="file";
filename="Data-Did_2013-03-03_06-05-15-6352000_Fid_114.plf"
Content-Type: application/octet-stream

‰

I actually need the bytes in the sent file.
Can someone send me a short code example on how to do it?
Regards,
Nir

Re: receiving a multipart entity at a http server

Posted by Nir Dweck <ni...@vasco-de.com>.
Oleg.
thank's a lot.
I started to understand that this is the case and you assured my assumption.
regards,
Nir



On Wed, Apr 10, 2013 at 10:27 AM, Oleg Kalnichevski <ol...@apache.org>wrote:

> On Tue, 2013-04-09 at 16:37 +0300, Nir Dweck wrote:
> > Hi,
> > I am trying to receive a multipart entity at my http server and am having
> > trouble to parse it.
> > The request includes a header:
> > Content-Type: multipart/form-data;
> > boundary=-------------------------acebdf13572468
> > my code does the following:
> > BasicHttpEntity entity = (BasicHttpEntity)entityReq.getEntity();
> > long len = entity.getContentLength();
> > byte[] data = new byte[(int)len];
> > int read = entity.getContent().read(data, 0, (int)len);
> >
> > and when I look at the the read bytes they hold:
> > includes a BasicHttpEntity and when I read it I see the content is:
> > ---------------------------acebdf13572468
> > Content-Disposition: form-data; name="file";
> > filename="Data-Did_2013-03-03_06-05-15-6352000_Fid_114.plf"
> > Content-Type: application/octet-stream
> >
> > ‰
> >
> > I actually need the bytes in the sent file.
> > Can someone send me a short code example on how to do it?
> > Regards,
> > Nir
>
> Nir
>
> HttpClient does not provide a mime parser. You should consider using
> either Commons Upload [1] or Mime4j [2] to parse multipart content on
> the server side.
>
> Oleg
>
> [1] http://commons.apache.org/proper/commons-fileupload/
> [2] http://james.apache.org/mime4j/index.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: receiving a multipart entity at a http server

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2013-04-09 at 16:37 +0300, Nir Dweck wrote:
> Hi,
> I am trying to receive a multipart entity at my http server and am having
> trouble to parse it.
> The request includes a header:
> Content-Type: multipart/form-data;
> boundary=-------------------------acebdf13572468
> my code does the following:
> BasicHttpEntity entity = (BasicHttpEntity)entityReq.getEntity();
> long len = entity.getContentLength();
> byte[] data = new byte[(int)len];
> int read = entity.getContent().read(data, 0, (int)len);
> 
> and when I look at the the read bytes they hold:
> includes a BasicHttpEntity and when I read it I see the content is:
> ---------------------------acebdf13572468
> Content-Disposition: form-data; name="file";
> filename="Data-Did_2013-03-03_06-05-15-6352000_Fid_114.plf"
> Content-Type: application/octet-stream
> 
> ‰
> 
> I actually need the bytes in the sent file.
> Can someone send me a short code example on how to do it?
> Regards,
> Nir

Nir

HttpClient does not provide a mime parser. You should consider using
either Commons Upload [1] or Mime4j [2] to parse multipart content on
the server side.

Oleg 

[1] http://commons.apache.org/proper/commons-fileupload/
[2] http://james.apache.org/mime4j/index.html


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