I've got a problem sending file with POST Request. If fileName has brackets , then server doesn't receive file at all, otherwise server receive file with name I inserted.
I've already tried to use
- volley library
- appach httpmime different versions
- Android Asynchronous Http Client
and I experience the same result.
Here is code I use
String fileName = "link[image]";//name of the parameter
HttpContext localContext = new BasicHttpContext();
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setLaxMode();
builder.setCharset(Charset.forName("UTF-8"));
builder.addBinaryBody(fileName, image, ContentType.APPLICATION_OCTET_STREAM, image.getName());//image - it's a File
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(URL);
HttpEntity entity = builder.build();
post.setEntity(entity);
HttpResponse response = client.execute(post, localContext);
HttpEntity httpEntity = response.getEntity();
String result = EntityUtils.toString(httpEntity);