AppUpload Method (CLIENT)


PLB Web Only, 9.9

 

The AppUpload method transfers a file from the client application to the PWS server. The method uses the following format:

 

[label]

{object}.AppUpload

[GIVING {return}] USING [*URL=]{url}[:

 

 

[*FileName=](filename}][,[*Options=]{options}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A CLIENT object.

return

Optional. A Numeric Variable that returns the success or failure of the method.

url

Required. A Character String Variable or string literal giving the URL of the file to upload from the PWS server.

filename

Required. A Character String Variable or string literal giving the file name to use on the server.

options

Optional. A Character String Variable or string literal that specifies a JSON object that is passed directly to the Cordova routine used for this method.

Flags Affected: OVER, ZERO

Note the following:

  1. This method is only used for a Sunbelt PL/B Web Client App using Cordova\PhoneGap operations. See the following link for details on the Cordova plugin used:

  2.  

         https://www.npmjs.com/package/cordova-plugin-file-transfer

     

  3. The ZERO flag is set when the {return} value is zero.

  4. The OVER flag is set if the value returned is too large to be stored into the {return} variable.

  5. The (options} parameter is passed directly as a JSON object to the Cordova routine. This currently only supports mimeType field as follows:

  6.  

    Field

    Description

    mimeType

    The mime type of the data to upload. Defaults to image/jpeg` mime type.

     

  7. This method starts an asynchronous upload of a file from the client to the PWS server. A result is generated using the PLB 'AppEventDoUpload' CLIENT object event with the event data being returned in ARG1 in JSON notation.

  8.  

    The event number used in EVENTREG is:

     

    AppEventDoUpload EQU 104 //Event number for EVENTREG.

     

    The event data returned by this method can be either a FileTransferError Object or a FileUploadResult JSON object returned in the ARG1 parameter.

     

    FileUploadResult JSON object fields defined as follows:

     

    Field

    Description

    code

    One of the predefined error codes listed below:

     

    FILE_NOT_FOUND_ERR EQU 1

    INVALID_URL_ERR EQU 2

    CONNECTION_ERR EQU 3

    ABORT_ERR EQU 4

    NOT_MODIFIED_ERR EQU 5

    responseCode

    The HTTP response code returned by the server.

    response

    The HTTP response returned by the server.

 

 

Example Code

 

ResultData DIM 500

.

      EventReg Client,AppEventDoUpload,UploadDoneFunc,ARG1=ResultData

.

      Client.AppUpload Giving Result:

             Using "cdvfile://localhost/persistent/Bill1.txt":

             "Bill2.txt"

 

 

See Also: CLIENT, Client Methods, Method Syntax



PL/B Language Reference AppStatusBar Method (CLIENT) AppVibrate Method (CLIENT)