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 Andreas Reichel <an...@i-kit.de> on 2008/10/31 09:06:38 UTC
Set Content type for multipart
Hi all,
I've tried several hours without success to create a multipart, that has
Content-Type: image/png.
This code:
--
File file = File.createTempFile("chart", ".png");
ImageIO.write(rendImage, "png", file);
reqEntity.addPart("fileName", new FileBody(file));
--
always creates octet/stream, that the server does'nt recognize.
Please would you give me a friendly hint or even a small example?
I thank you in advance!
Best regards!
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Set Content type for multipart
Posted by Christine <ch...@christine.nl>.
Actually, subclassing MultipartEntity only works if you override
generateContent with a fixed return string. I made a setMimeType method
that sets a mimeType that is returned in the generateContentType, but
that returns null. So I now subclass MultipartEntity, but there's only
one content type that I can get.
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
--
dagdag is just a two character rotation of byebye
www.christine.nl
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Set Content type for multipart
Posted by Christine <ch...@christine.nl>.
You can extend FileBody, and extend "getContentType" to return what you
set with a new method "setContentType"
Christine
On Fri, 2008-10-31 at 09:06 +0100, Andreas Reichel wrote:
> Hi all,
>
> I've tried several hours without success to create a multipart, that has
> Content-Type: image/png.
> This code:
> --
> File file = File.createTempFile("chart", ".png");
> ImageIO.write(rendImage, "png", file);
> reqEntity.addPart("fileName", new FileBody(file));
> --
> always creates octet/stream, that the server does'nt recognize.
>
>
> Please would you give me a friendly hint or even a small example?
> I thank you in advance!
> Best regards!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
--
dagdag is just a two character rotation of byebye
www.christine.nl
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Set Content type for multipart
Posted by Christine <ch...@christine.nl>.
On Fri, 2008-10-31 at 09:06 +0100, Andreas Reichel wrote:
> Hi all,
>
> I've tried several hours without success to create a multipart, that has
> Content-Type: image/png.
You can set the content type for the entity as a hole. I asked the same
question about individual parts only a couple days ago.
This is what I have:
httpPost.setParams(params);
httpPost.setEntity(multipartEntity);
httpPost.addHeader("Authorization", "GoogleLogin auth="
+ mAuthToken);
httpPost.addHeader("Content-Type", "image/jpeg");
Christine
> This code:
> --
> File file = File.createTempFile("chart", ".png");
> ImageIO.write(rendImage, "png", file);
> reqEntity.addPart("fileName", new FileBody(file));
> --
> always creates octet/stream, that the server does'nt recognize.
>
>
> Please would you give me a friendly hint or even a small example?
> I thank you in advance!
> Best regards!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
--
dagdag is just a two character rotation of byebye
www.christine.nl
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org