@Joe LaPenna
I am trying to send multipart to google appengine as well and
struggling. Do you have any specific instructions that might help?
On Oct 12, 12:56 am, "Joe LaPenna" <[EMAIL PROTECTED]> wrote:
> By chance is the web server google app engine? Even if it isn't there is a
> chance your server does not support chunked transfer encoding. If for
> example any part of your multipart message is an inputstream part then the
> library will set the post using chunked encoding. I got around this in gae
> creating my own inputstream. Part that supported getcontentlenght and the
> other method that specified that reading the stream did not consume it. (I
> returned a copy of the stream when it is requesrted). Sorry if this is a bit
> vague, I'm away from the code I wrote at the moment.
>
> On Oct 7, 2008 8:52 PM, "Vinod B" <[EMAIL PROTECTED]> wrote:
>
> hi,
> I am sending an http post of a multipart (form-data) as shown below to
> an apache web server. It returns an error saying the Content-length
> header needs to be specified. Looking at the trace, the Content-Length
> header is indeed not being set in the request. I tried getting the
> content length using requestContent.getContentLength () only to get
> -1.
> So any pointers on what to do for this problem?
> thanks,
> -Vinod
>
> On Aug 19, 4:18 pm, "Justin (Google Employee)" <[EMAIL PROTECTED]>
> wrote:> Just to finish this thread off nicely, here's some code to
>
> usemultipartposts. Again, you need mime4j, httpmime, and Apache Commons
>
> > IO.
>
> > import java.io.ByteArrayInputStream;
> > import java.io.InputStream;
> > import org.apache.http.client.HttpClient;
> > import org.apache.http.client.methods.HttpPost;
> > import org.apache.http.entity.mime.MultipartEntity;
> > import org.apache.http.entity.mime.content.ContentBody;
> > import org.apache.http.entity.mime.content.InputStreamBody;
> > import org.apache.http.entity.mime.content.StringBody;
> > import org.apache.http.impl.client.DefaultHttpClient;
> > ...
> > HttpClient httpClient = new DefaultHttpClient();
> > HttpPost request = new HttpPost("http://www.example.com");
>
> > // we assume 'data' is some byte array representing a jpeg
> > InputStream ins = new ByteArrayInputStream(data);
> > parts[0] = new InputStreamBody(ins, "image.jpg");
> > parts[1] = new StringBody("some bit of information");
> > parts[2] = new StringBody("another bit of information");
>
> > // create themultipartrequest and add the parts to it
> > MultipartEntity requestContent = new MultipartEntity();
> > requestContent.addPart("image.jpg", parts[0]);
> > requestContent.addPart("data_part1", parts[1]);
> > requestContent.addPart("data_part2", parts[2]);
>
> > // execute the request
> > request.setEntity(requestContent);
> > httpClient.execute(request);
>
> > The HttpClient execute method will give you a handle to the response.
> > From that you can do HttpResponse.getEntity().getContent() which will
> > give you an InputStream to read the response. Unfortunately the
> > InputStream doesn't produce a meaningful response for
> > InputStream.available(). This might be because somewhere along the way
> > the Content-Length header seems to be getting lost, but I haven't had
> > time to look into this further yet.
>
> > Cheers,
> > Justin
> > Android Team @ Google
>
> > On Aug 18, 11:13 pm, code_android_festival_way
>
> > <[EMAIL PROTECTED]> wrote:
> > > Thank you Justin for helping me out. It is working pretty fine
> > > now. :-)
>
> > > Cheers from Germany!
>
> > > On 19 Aug., 02:11, "Justin (Google Employee)" <[EMAIL PROTECTED]> wrote:
>
> > > > Looks like you also need the Apache Commons IO library which you can
> > > > get fromhttp://commons.apache.org/io/.
>
> > > > Cheers,
> > > > Justin
> > > > Android Team @ Google
>
> > > > On Aug 18, 3:19 pm, code_android_festival_way
>
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > So I'm back with a question. I've imported the libraries mentioned
> > > > > above and got the following setup:
>
> > > > >http://paste.pocoo.org/show/82631/
>
> > > > > Now I get an error while executing the POST method with the
> > > > > HttpClient. Am I doing sth. wrong or what do I have to change to get
> > > > > it working. (the paste above is cutted down to the most important
> > > > > parts)
>
> > > > > The error message:
>
> > > > > Error in ....org.apache.commons.io.ouput.ByteArrayOutputStream
>
> > > > > I'm looking forward getting some answers.
>
> > > > > Regards!
>
> > > > > On 18 Aug., 22:35, code_android_festival_way
>
> > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > Thank you for your answer Dan.
>
> > > > > > I'm looking now how to get the whole thing working. (since I'm not
> the
> > > > > > best Java developer :) )
>
> > > > > > I will come back with the results later on.
>
> > > > > > On 18 Aug., 22:26, "Dan Morrill" <[EMAIL PROTECTED]> wrote:
>
> > > > > > > To shed a bit more light, the reason the multi-part APIs were
> removed is
> > > > > > > because those APIs will not be final in the upstream Apache
> HTTPClient in
> > > > > > > time for Android's schedule for a final 1.0 version. Rather
> than ship an
> > > > > > > early/incompatible API, we chose to remove it, and rely on other
> libraries
> > > > > > > as Justin suggested.
>
> > > > > > > Note that this applies only to the multi-part APIs: the rest of
> the Apache
> > > > > > > HTTPClient APIs have been frozen, and so they are "safe" for us
> to include.
> > > > > > > (Seehttp://
>
> www.nabble.com/-VOTE--RESULT--HttpClient-4.0-API-freeze-td1863...> > > > > > )
>
> > > > > > > - Dan
>
> > > > > > > On Mon, Aug 18, 2008 at 1:10 PM, Justin (Google Employee) <
>
> [EMAIL PROTECTED]>wrote:
>
> > > > > > > > Note that this has been removed because it was removed from
> the Apache
> > > > > > > > HttpClient library that we're bundling. What you want to do is
> get
> > > > > > > > Mime4j (http://james.apache.org/mime4j/index.html) and
> HttpMime
> > > > > > > > (
>
> http://hc.apache.org/httpcomponents-client/httpmime/index.html) and
>
> > > > > > > > include these libraries in your Android project. From there,
> the usage
> > > > > > > > ofmultipartrequests is pretty intuitive.
>
> > > > > > > > Cheers,
> > > > > > > > Justin
> > > > > > > > Android Team @ Google
>
> > > > > > > > On Aug 18, 1:06 pm, code_android_festival_way
> > > > > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > > > > Hello guys.
>
> > > > > > > > > I've seen that themultipartmethod has been removed in 0.9.
> I'm
> > > > > > > > > wondering now how to achieve these messages now.
>
> > > > > > > > > At the moment I'm having something like:
>
> > > > > > > > >http://paste.pocoo.org/show/82610/
>
> > > > > > > > > Is there an example how to do that in the 0.9 release? I've
> looked at
> > > > > > > > > the Mime4j library but didn't get the point how this works.
>
> > > > > > > > > It would be very nice if someone could provide an example
> for me.
>
> > > > > > > > > Regards!- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---