This example developed for a support case, shows how to loop through multiple parts of a form-data message get the file name for each part and upload it to a remote ftp site.
Here is the message we have in PostMan, where we have two .pdf files that are to be part of the posted content :
<Please see attached file for image>
Using fiddler we can see the raw data that is POST'ed when the message is sent to the gateway server. Note the Content-Disposition header field that contains the filename :
<Please see attached file for image>
The policy that receives the content loops over the ${requests.parts}, and processes each on separately.
<Please see attached file for image>
We isolate the "dataToSend" as a Message - (we picked application/octet-stream as content-type, as it needed to be hardcoded. It would have been good to set it from the ${items.current.contentType} but that wasnt possible)
We also extract filename from the Content-Disposition header using regex.
Then we call the "Route Via FTP" assertion as per :
<Please see attached file for image>
passing in the ${filename} and the ${dataToSend} as the content.
Here we can see the first pdf file being transferred.
<Please see attached file for image>
And on the ftp site we can then see the two transferred files.
<Please see attached file for image>