Questions tagged [multipartentity]

MultipartEntity is successor of HttpEntity, contained in HttpMime API since version 4.0. It's use is primary to simplify process of posting multipart content over HTTP. It allows to add multiple parts of different content-type and encoding.

MultipartEntity, part of HttpMime 4.0 and later. Allows you to put multiple parts, separated by boundary strings and encoded using given charset, into request.

It can have different modes, based on HttpMultipartMode constants. RFC Strict mode ( RFC 822, RFC 2045, RFC 2046 compliant ) and Browser compatible mode.

Each part of request is set via addPart(String name, ContentBody body) or addPart(FormBodyPart body) method.

Note that request, can have only one entity set, so all data must be fit in MultipartEntity object.

232 questions
5
votes
3 answers

what is the standard way to post JSON Object along with file using MultipartEntityBuilder and HTTP Client in Android

I am able to post json object using StringEntity using httppost.setEntity(newStringEntity(obj.toString())); HttpResponse response = httpclient.execute(httppost); but I have to post a file along with json data , I have found many Answers Using …
4
votes
1 answer

How to Pass String Variable in MultipartEntity?

I am passing 3 images in MultipartEntity. This works good, but I don't know how to pass a String value into MultipartEntity. The following is my code: public void executeMultipartPost(Bitmap bm, int i) throws Exception { try { …
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
4
votes
1 answer

Edit headers of MultiPartEntity

I'm making a XML + image post in my Android application with a MultiPartEntity and every thing is good except the server that I'm posting to requires me to set the Content-Typeof the HTTP post to application/soap+xml; charset="utf-8" So how do I get…
Mats Hofman
  • 7,060
  • 6
  • 33
  • 48
4
votes
0 answers

Multipart Image Request with JSON params in Single Call using volley Framework

I am sending multipart Post request in Volley along with the JSon params {as required by server } , but at server side null params are received . In this request, I need to send Requested params in one part fist, and the image file in the next part…
4
votes
3 answers

Entity returns error in MultiPartEntityBuilder

I've tried following links but none of them helped to solve the issue. HttpPost returning error when using MultipartEntityBuilder in Android https://stackoverflow.com/a/22803149/1226882 Here's the code HttpClient httpClient = new…
moDev
  • 5,248
  • 4
  • 33
  • 63
4
votes
2 answers

How to open a file in raw folder in Android

I am usin MultipartEntity and I am trying to refer to the file in the raw folder. Here is the code: MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart(new FormBodyPart("file", new FileBody(new File("test.txt")))); The test.txt…
Nemin
  • 1,907
  • 6
  • 24
  • 37
4
votes
2 answers

Multipart Request issue in android - Throwing BAD REQUEST

private void CreateaMultiPartRequest() { try{ HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://172.16.22.232:8080/RESTfulExample/rest/multiPartFileUpload"); MultipartEntity reqEntity = new…
Rahul Raj
  • 367
  • 3
  • 17
4
votes
0 answers

Best method to Upload images to php server in Android ?

In my application I need to upload image from Android to php server. I used multipartentity and it worked for me.Can anyone suggest me a method which is faster than this.I need to upload 4 pictures from my application at one time.So it takes a lot…
SREEJITH
  • 816
  • 1
  • 8
  • 19
4
votes
1 answer

Android MultipartEntity POST receive everything besides FileBody

After reading a lot of Questions and answers, I've decided to use MultipartEntity. This Answer must be the best: https://stackoverflow.com/a/2937140/1388723 I've implemented it: private class SendImage extends AsyncTask { …
BAZTED
  • 546
  • 5
  • 16
4
votes
2 answers

MultipartEntity and Json

I want to send an image and a JsonObject to an PHP Server with MultipartEntity. Here is my Code: HttpClient httpClient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(urlString); File file = new File(imageend); HttpResponse response =…
t18935
  • 59
  • 1
  • 6
3
votes
0 answers

Constructing a multipart request from InputStream with Apache Async HTTP Client

I am trying to send a multipart request through apache async http client, but getting a org.apache.http.ContentTooLongException: Content length is unknown error. I do understand why content length is required in an asynchronous model, but want to…
3
votes
5 answers

Encode filename in MultipartEntityBuilder

I am trying a file upload API using HttpPost and MultipartEntityBuilder. Following is the code I have used. MultipartEntityBuilder builder =…
Sabitha
  • 273
  • 4
  • 14
3
votes
1 answer

How to force RestTemplate to send multipart/form-data with UTF-8 encoding

I am struggling to have my multipart/form-data encoded in UTF-8 in RestTemplate entity. I don't know what am I doing wrong. Below I posted my code LinkedMultiValueMap map = new LinkedMultiValueMap<>(); map.add("text",…
dune76
  • 373
  • 1
  • 5
  • 10
3
votes
1 answer

Multipart File upload using Apache REST client

I was trying to upload files to OneDrive using multipart request. I've tried many ways but none of them worked. The request is of the form :- POST /drive/items/{folder-id}/children Content-Type: multipart/related;…
Sachin
  • 1,675
  • 2
  • 19
  • 42
3
votes
1 answer

How to know if the httpservletrequest contains some files/images?

In the following code: public static MultipartEntity buildMultiEntity(final SlingHttpServletRequest request) { MultipartEntity multipartEntity = null; final Map params =…
Ronald
  • 2,721
  • 8
  • 33
  • 44
1
2
3
15 16