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
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 this example the help2 function returns an integer in the header and a string and a text file as multipart in the body.
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.