Attach files with WSAttachment and WSMedia
In GWS REST attachments are handled via the WSAttachment and WSMedia attributes.
If a parameter has a WSAttachment attribute, the REST engine treats the parameter value as a path to a file to be attached, while the data format of the file can be specified in the WSMedia attribute.
Attaching files in request and response
In this function, an image file is sent to the server in the request and another image
is returned to the client. The wildcard in
WSMedia
allows for all image types:
IMPORT os
PUBLIC FUNCTION EchoFile( input STRING ATTRIBUTE (WSAttachment,WSMedia="image/*") )
ATTRIBUTES(WSPost)
RETURNS STRING ATTRIBUTE (WSAttachment, WSMedia="image/*")
DEFINE ok INTEGER
LET ok = os.path.rename(input, "MyFile.png")
RETURN "/usr/local/MyOtherFile.jpg"
END FUNCTION