uploadFile


Purpose

Allows to send a file from the device to a specified server.

Note

This method has been deprecated and will soon be removed from the exposed API set. It is recommended that you use the File Transfer API instead.

Signature

uploadFile(fileUri, url, options, callbacks)

Returns

This method does not return anything.

Parameters

Name Description Type Use
fileUri A File API-compatible path to the file. string required
url

A string value specifying the address of the receiving server.

string required
callbacks

Passed to verify whether it is possible to acquire a file.

undefined required
options

Configuration passed to the function call.

object required

The uploadFile method's callbacks object can be structured as follows:

{
  onSuccess: function(result)
    {
      printText('File upload success, name ' + result.fileName + ' ' + result.message)
    },
  onFailure: function(error) {...}
}

The table below lists all callbacks supported by the method.

Name Description Type Use
onSuccess()

A function called when the process succeeds. As a parameter, it takes an object with the following two properties:

  • result.fileName - a name of the uploaded file,

  • result.message - a response from the server that has accepted the file.

function required
onFailure() A function called when the file cannot be uploaded. It passes an error message. function required

The uploadFile method's options object looks like in the following example.

{ url, fileUri, name, jsonParams }
Name Description Type Use
name Form-data "name" variable (please see the rfc1867 specification). If "null" or undefined is used, it will be overriden by the name of the uploaded file. string required
jsonParams

A JSON object containing HTTP header request key values. It may be empty.

{ KEY1: "value1", KEY2: "value2" }
object required

Related topics

Overview
Legal notice | Copyright © 2017 and Confidential to Pegasystems Inc. All rights reserved
PDN | Feedback
Advanced...