You define process output field (s) of type Attachment (or Attachments). These fields are returned as attachments to the caller.
For example, if the process has input fields "first" (Text), "last" (Text), and "inputFile" (Attachment), the payload would be similar to the following:
POST /active-bpel/public/rt/Attachments_Test HTTP/1.1
Content-Type: multipart/form-data; boundary=----TheBoundary1234
------TheBoundary1234
Content-Disposition: form-data; name="first"
John
------TheBoundary1234
Content-Disposition: form-data; name="last"
Smith
------TheBoundary1234
Content-Disposition: form-data; name="inputFile"; filename="filename.png"
Content-Type: image/png
... binary image data ...
------TheBoundary1234--
The first part of the response should be a JSON document describing the response output fields. The JSON content will have the output field values (standard response).
If the output field is of type Attachment, the value will be a string containing the content-id (cid) of the part containing the attachment. For example, if the output fields are the "first" (Text), "last" (Text), and "inputFile" (Attachment), the response should look similar to:
Content-Type: multipart/mixed; boundary=----TheBoundary1234
------TheBoundary1234
Content-Type: application/json
{
"first" : "John",
"last" : "Smith",
"inputFile" : "cid:fc1c6030-4b90-4981-b9d8-ab1d0ba0e84e"
}
------TheBoundary1234
Content-Type: image/png
Content-Name: photo
Attachment-Created-At:1435182142837
Content-Id: fc1c6030-4b90-4981-b9d8-ab1d0ba0e84e
Content-Length: 1073
... binary image data ...
------TheBoundary1234--