The JSMA responseĀ allows to manipulate the response that will be sent to the client
What canĀ JSMA response do for me?You could use the JSMA response to manipulate the response that will be sent to the client |
Here is an example on how to write data to a JSMA response:
... var mimeType = request.parameter("mimetype"); var fileId = request.parameter("id"); var file = files.findById(fileId); if (file !== null) { response.sendFile(file, mimeType); } ... |
Here is an example on how to read data from a JSMA response :
... response.header ... |
The JSMA file response the following methods:
Returns the header of the response
... response.header ... |
Sets the status code of the response to the given error code
... var file = files.findByUuid(request.parameter('id')); if (file === null) { response.sendError(404); return; } ... |
Sets a JSMA file to be sent as the response body.
... var mimeType = request.parameter("mimetype"); var fileId = request.parameter("id"); var file = files.findById(fileId); if (file !== null) { response.sendFile(file, mimeType); } ... |
Sends a redirect response to the client
... response.sendRedirect(target, [temp]) ... |
Sets a key/value pair in the response headers.
... response.setHeader(key, value) ... |