Working POST Multipart Request with Volley and without HttpEntity

前端 未结 5 1400
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 09:55

This is not really a question, however, I would like to share some of my working code here for your reference when you need.

As we know that HttpEntity

5条回答
  •  生来不讨喜
    2020-11-22 10:12

    Just want to add to the answer. I was trying to figure how to append text fields to the body and created the following function to do it:

    private void buildTextPart(DataOutputStream dataOutputStream, String parameterName, String parameterValue) throws IOException {
        dataOutputStream.writeBytes(twoHyphens + boundary + lineEnd);
        dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"" + parameterName + "\"" + lineEnd);
        dataOutputStream.writeBytes("Content-Type: text/plain; charset=UTF-8" + lineEnd);
        dataOutputStream.writeBytes(lineEnd);
        dataOutputStream.writeBytes(parameterValue + lineEnd);
    }
    

    It is working pretty well.

提交回复
热议问题