I am using groovyx.net.http.HTTPBuilder to POST from Grails to a PHP script. I need to attach a couple of text fields and a number of files.
I can attach a few textfields this way with great success:
MultipartEntity mpc = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE)
mpc.addPart("json", new StringBody(json.toString()))
But, when I attach a file like this, the textfields are no longer present in the request:
passFiles.each() { key, value ->
mpc.addPart(key, new InputStreamBody(value.stream, value.type, value.filename))
System.out << value
}
I think the file should be okay to add this way. Here is my trace from the above:
[filename:icon.png, stream:java.io.ByteArrayInputStream@2747ebcb, type:image/png]
How can I cause HTTPBuilder to make this Multipart POST as intended?