You can pass multipart mime messages through the Gateway. All of the parts are available to the Policy if needed, although usually, we may only work on the first one which would typically be the JSON payload being posted.
I just ran a test where I used curl to post a multipart/mixed request with a JSON payload as the first part and an 8MB mp4 movie as the second. The policy at the first Gateway has nothing more than a routing assertion that forwards it to a second Gateway. This simulates the passthrough. The service at the second Gateway parses the mime contents and returns a simple report. It also runs a JSON path on the request message, with the result added to the report.
Here is the policy on the first Gateway:
Here is the corresponding policy on the second Gateway:
And finally, the curl call in all its glory:
jay@harkness ~ $ curl -H "Content-Type: multipart/mixed" -F "metadata=@simple.json; type=application/json" -F "content=@Downloads/VID_20160829_211934.mp4; type=video/mp4" -X POST http://ssg91.l7tech.com:8080/mimeTest/proxy -i
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/plain;charset=UTF-8
Content-Length: 170
Date: Wed, 07 Sep 2016 23:12:38 GMT
OK from ssg83.l7tech.com
JSON Path result=SGML
multipart/mixed; boundary=----------------------------155dc43456f0 - 8673445
application/json - 583
video/mp4 - 8672506jay@harkness ~ $
As you can see it executed the JSON path correctly and accepted the entire video that was attached. I ran the same test with a 500MB video file without issue. I'm not sure what the actual limit is for mime. Note that the io.xmlPartMaxBytes cluster property limits the size of an XML document, but not any mime attachments.
You certainly could put it in the body, but that might cause a huge performance hit if the message requires parsing. Assuming the image itself is never actually touched by the Gateway, why bother parsing it?
So I think the best approach, in this case, is to use Multipart MIME to build out the request to POST rather than put it in the body.
I hope that helps.