The InboundMultiPart handler is used to send and receive MIME multipart content.
Refer to 5.1.6 Web Browser Content.
|
A web browser can send content using the multipart/form-data format.
<FORM METHOD="POST" ACTION="http://server1/cgi-bin/jsmdirect?upload" ENCTYPE="multipart/form-data">
<INPUT NAME="COMPANY" TYPE="TEXT" SIZE ="30"/>
<INPUT NAME="FILE1" TYPE="FILE" SIZE ="60"/>
<INPUT NAME="FILE2" TYPE="FILE" SIZE ="60"/>
<INPUT NAME="FILE3" TYPE="FILE" SIZE ="60"/>
<INPUT TYPE="SUBMIT" VALUE="Send order"/>
</FORM>
If the specified FILE, FIELD, FILENAME or INDEX component does not exist then a command status of NOT_EXIST is returned.
If the FILE component does exist but has not been used, then NOT_EXIST is also returned.
Example
Receive content from a Web browser post.
RECEIVE HANDLER(InboundMultiPart) FIELD(COMPANY)
RECEIVE HANDLER(InboundMultiPart) FIELD(COMPANY) ENCODING(MS932)
In the following example the file selected as FILE2 is uploaded to the location and new name given in TO parameter.
RECEIVE HANDLER(InboundMultiPart) FILE(FILE2) TO(/folder/file.jpeg)
In this example it is the name of the FILE2 (i.e. C:\images\holiday.jpeg) selected in the browser that is passed to the LANSA function (i.e. holiday.jpeg).
RECEIVE HANDLER(InboundMultiPart) FILENAME(FILE2)
When the SEND command of this content handler is executed the following steps occur:
1. The working list argument is used to create a MIME MultiPart response.
2. The name value pair data and the file data are passed using a list argument.
3. An optional fourth field controls how the file contents are MIME encoded. Possible values are 8bit or base64. The default MIME encoding is 8bit. The MIME body part Content-Type is determined by the file extension using the Java Activation Framework.
The field value encoding is determined by the ENCODING keyword.
Example
DEFINE FIELD(#TYPE) TYPE(*CHAR) LENGTH(10)
DEFINE FIELD(#NAME) TYPE(*CHAR) LENGTH(20)
DEFINE FIELD(#VALUE) TYPE(*CHAR) LENGTH(100)
DEF_LIST NAME(#WRKLST) FIELDS(#TYPE #NAME #VALUE) TYPE(*WORKING)
CHANGE FIELD(#TYPE) TO(FIELD)
CHANGE FIELD(#NAME) TO(COMPANY)
CHANGE FIELD(#VALUE) TO(ACME)
ADD_ENTRY TO_LIST(#WRKLST)
CHANGE FIELD(#TYPE) TO(FILE)
CHANGE FIELD(#NAME) TO(ORDER_FILE)
CHANGE FIELD(#VALUE) TO('''/order/month-order.xml''')
ADD_ENTRY TO_LIST(#WRKLST)
CHANGE FIELD(#JSMCMD) TO('SEND HANDLER(InboundMultiPart) SERVICE_LIST(TYPE,NAME,VALUE)')
Syntax:
|
Example
SEND HANDLER(InboundMultiPart) #WRKLST(TYPE,NAME,VALUE)