1

I have some arguments in multiPartRequest post along with image. It replaces all spaces with + sign. eg: if titleString is "Hey there", it uploads "Hey+there". I've checked the same api with connectionRequest which works alright.

public static void multipartConnection(String picture, String title, String description) {
    if (picture != null) {
        MultipartRequest request = new MultipartRequest() {
            protected void readResponse(InputStream input) throws IOException {
                JSONParser jp = new JSONParser();
                Map<String, Object> result = jp.parseJSON(new InputStreamReader(input, "UTF-8"));
            }

            @Override
            protected void postResponse() {

            }

        };
        request.setPost(true);
        request.setUrl(urlString);
        request.setTimeout(5000);
        request.addArgument("title", title);
        request.addArgument("description, description);

        if (picture != null && !picture.equals("")) {
            try {
                request.addData("image", picture, "image/jpeg");
                request.setFilename("image", "myPicture.jpg");
            } catch (IOException err) {
                System.out.println("bbeck " + err);
            }
        }
        request.addRequestHeader("Accept", "application/json");
        NetworkManager.getInstance().addToQueue(request);
    }
}
beck
  • 2,967
  • 3
  • 16
  • 27

1 Answers1

0

That's how multipart works: URL encoding the space character: + or %20?

The MultipartRequest class works like a HTML form submit that includes a file. If you try that in a web browser you will see + signs too. If you use proper multipart handling on the server side (which is pretty standard) you will get proper spaces parsed out.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65