I am using the answer here to try to make a request POSTwith data loading, but I have unusual requirements from the server side. The server is a PHP script for which it is required filenamein a line Content-Dispositionbecause it expects a file to load.
Content-Disposition: form-data; name="file"; filename="-"
However, on the client side, I would like to place a buffer (in this case String) in the memory instead of a file, but the server processes it as if it were a file upload.
However, using StringBody, I cannot add the required field filenameto the string Content-Disposition. So I tried using FormBodyPart, but just put it filenameon a separate line.
HttpPost httppost = new HttpPost(url);
MultipartEntity entity = new MultipartEntity();
ContentBody body = new StringBody(data,
org.apache.http.entity.ContentType.APPLICATION_OCTET_STREAM);
FormBodyPart fbp = new FormBodyPart("file", body);
fbp.addField("filename", "-");
entity.addPart(fbp);
httppost.setEntity(entity);
filename Content-Disposition, String , ?