BBjHttpRequest::getFileUploads

Description

In BBj 14.0 and higher, this method returns a BBjVector of BBjFileUpload objects that have been posted and available in a BBjHttpRequest object.

Syntax

Return Value

Method

BBjVector

getFileUploads()

Parameters

None.

Return Value

Returns aBBjVector.

Remarks

The example below demonstrates how a servlet can retrieve the details for uploaded files.

Example

REM Obtain the instance of the BBjAPI object

LET myAPI!=BBjAPI()

MyServlet! = new MyServlet()

 

data!.setCallback(data!.ON_WEB_CONNECTION, myServlet!, "myMethod")

 

PROCESS_EVENTS

 

class public MyServlet

  method public void myMethod(BBjServletEvent p_event!)

    LET chan = UNT

    request! = p_event!.getHttpRequest()

    response! = p_event!.getHttpResponse()

    resp!.setContentType("text/html")

    open(chan)"JSERVLET"

    print(chan)"<html><body><h1>Hello BBj!</h1>"

    declare BBjVector files!

    files! = request!.getFileUploads()

    sz = files!.size()

    if sz then

      declare BBjFileUpload uploadFile!

      print(chan)"There were " + str(sz) + " files uploaded.<br>"

      for i=0 to sz-1

        uploadFile! = cast(BBjFileUpload,files!.get(i))

        print(chan)"Name:"+ uploadFile!.getOriginalName()

        print(chan)"- as:"+ uploadFile!.getTempName()

        print(chan)"<br>"

      next i

    else

      print(chan)"There were no files uploaded, please upload some:<br>"

    fi

    print(chan)"</body></html>"

    close(chan)

  methodend

classend

See Also

BBjAPI

BBjServletEvent

BBjHttpRequest

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.