Download a file in a multipart response
This example demonstrates how to return a file in a form-data type HTTP multipart response while also transferring data of other types in the same message response.
Example multipart response
In this example an integer is returned in the header and a string and a text file as multipart in the body.PUBLIC FUNCTION help2()
ATTRIBUTES (WSGet,
WSPath="/help2")
RETURNS (INTEGER ATTRIBUTE(WSHeader),
STRING,
TEXT ATTRIBUTE(WSName="txt_file") )
DEFINE t TEXT
CALL t.readFile("mytext.txt")
RETURN 3, "hello world", t
END FUNCTION
In the output the header is given the default name, "rv0", at runtime.
In the multipart response parts are combined into one or more sets of data in the body. Parts are
separated by boundaries, the --MIME_boundary
in the output example.
The text file part is identified by the name ("txt_file") that is defined via the WSName
attribute.
![Sample output of multipart HTTP response](Images/rest_response_multipart.png)