Starting with OpenEdge 10.1A, webspeed supports upload of binary/BLOB
data files.
The following code is an example of how to create an HTML form that
can upload a file:
Code:
<HTML><BODY>
<FORM ENCTYPE="multipart/form-data" ACTION="http://<yourhost>/<msngr
path>/<msngr>/ping" METHOD="POST">
<INPUT type="file" name="filename"> <INPUT type="submit">
</FORM>
</BODY></HTML>
To enable a WebSpeed application to accept binary/BLOB data from this
form, you must do following:
• Upgrade your WebSpeed Messenger to OpenEdge R10.1A. The Messengers
in previous versions cannot accept BLOBs.
• Specify a maximum size for uploaded files The maximum size is set
with the binaryUploadMaxSize property in the ubroker.properties file.
You can set it on the Agent>Advanced Features page of the WebSpeed
Transaction Server’s Properties sheet
• Write code to manipulate the uploaded file through its MEMPTR. This
code should ensure that the uploaded file contains no malicious
content before it is stored to disk. WebSpeed provides a new API
function "get-binary-data" to return the file’s MEMPTR.
Code:
/* This example shows how to retrieve the data from a file passed on a
given request, and save it as a file with the same name to the
WebSpeed's working directory. Note that 'filename' is the name of the
field in the form posted. */
DEFINE VAR mFile AS MEMPTR NO-UNDO.
DEFINE VAR cfile AS CHAR NO-UNDO.
/* 'filename' refers to the name of the field in the form.
get-binary-data returns the contents of the file associated with the
form field named
'filename'. */
ASSIGN mFile = get-binary-data("filename").
IF mFile <> ? THEN DO:
/* if we got a valid pointer, save data to file. The value of the
field
'filename' is the file name posted */
ASSIGN cfile = get-value("filename").
COPY-LOB FROM mFile TO FILE cFile NO-CONVERT.
END.