TubDocumentRequest

TubDocumentRequest

TubDocumentRequest

Constructor

new TubDocumentRequest(httpReqopt)

Container for raw document data extracted from incoming HTTP request for setDocument/setDocumentMultipart app level methods
Arguments:
  1. [httpReq] (THTTPRequest)  Optional HTTP request. In case passed content will be loaded from request body during constructor call

Members

entity: String

Entity code

attribute: String

Entity attribute code

id: Number

isDirty: Boolean

If true - content is stored in the temporary store

forceMime: String

MIME type to force convertion to (in case blob store sonfigured to support MIME convetration)

fileName: String

Name of file as it in the store

Methods

createHandlerObject(AEstablishStoreFromAttribute)

Arguments:
  1. AEstablishStoreFromAttribute (boolean)

saveBodyToFile(fileName)boolean

Save request body to file
Arguments:
  1. fileName (String)  name of file to save request body to

loadBodyFromFile(fileName)boolean

Arguments:
  1. fileName (String)

getBodyAsUnicodeString()string

setBodyAsUnicodeString(bodyAsString)

Transform unicode string to internal UFT8 buffer
Arguments:
  1. bodyAsString (String)

setBodyFromArrayBuffer(buffer)String

Read request body from array buffer and call TubDocumentRequest.writeToTemp method.
Arguments:
  1. buffer (ArrayBuffer)

getBodyAsBase64String()String

getIsBodyLoaded()boolean

setContent()

Set document content to internal request buffer (in-memory). Function implement UBWriter#write Call to this function not perform actual writing of document to store, to save document to store call TubDocumentRequest#writeToTemp

getContent()

Read document content. Content must be previously loaded. Function implement UBReader#read

writeToTemp(bodyopt, encodingopt)String

Write passed body to temporary store. If body is loaded it is possible to call writeToTemp without parameters.
Arguments:
  1. [body] (TubDocumentRequest|String)  Body to write. Can be copied from existing TubDocumentRequest or from string. In case body is loaded using TubDocumentRequest#write, it can be omitted
  2. [encoding] (String)  Optional. In case parameter exist and first parameter type is string - perform decode of body before write to store. Possible values: "bin", "base64"
Example
var
         pdfRequest = new TubDocumentRequest(),
         docContent;
     pdfRequest.entity = "rep_reportResult";
     pdfRequest.attribute = 'generatedDocument';
     pdfRequest.id = reportResultID;
     pdfRequest.fileName = reportResultID.toString() + '.pdf';

     docHandler = docReq.createHandlerObject(true);
     docHandler.loadContent(TubLoadContentBody.Yes);

     docContent = pdfRequest.writeToTemp(pdfDocument.pdf.output(), 'bin');