# Class Storage#upgradeApplication

storage

- Defined in: storage.js

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Storage#upgradeApplication(successCallback, errorCallback, options) Upgrades application stored in local or USB using the one from remote server.

## Class Detail

Storage#upgradeApplication(successCallback, errorCallback, options)

Upgrades application stored in local or USB using the one from remote server. Remote server information(serverIP and serverPort) is set in display menu.
New application will be launched at next boot time and old application will be deleted at the same time. Application on the server should be at
"http://serverIP:serverPort/procentric/scap/application/scap_app.zip".
Note : Size of scap_app.zip (zip file itself and extracted files) should not exceed free storage size of the platform.
When application is being upgraded, following files exist at the same time :
- old application
- downloaded scap_app.zip
- content data stored by storage.copyFile() API and
- new application extracted from the downloaded scap_app.zip
So before upgrading the application, call storage.getStorageInfo() and check the free storage size.
Note : Application should not include 'content' directory under application's root folder.
(It is reserved for Storage.copyFile() API.)

    function upgradeApplication() {
       var successCb = function (cbObject) {
         console.log("Application Update successful");
       };

       var failureCb = function(cbObject) {
         var errorCode = cbObject.errorCode;
         var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText);
       };

       var options = {
          to : Storage.AppMode.USB,
          recovery : false
       };

       var storage = new Storage();
       storage.upgradeApplication(successCb, failureCb, options);
    }

Parameters:
{Function} successCallback
  success callback function.
{Function} errorCallback
  failure callback function.
{Object} options

  Property | Type | Description | Required
  --- | --- | --- | ---
  to | String | Storage.AppMode | required
  type | String | Storage.AppType if there is no value, it will use application type value of 8080 server ui | optional
  recovery | Boolean | true : Recover old application if there was an error during upgrade. Default value. false : Remove old application to obtain free storage space. | optional

Since:
  1.0, 1.1 options.to options.recovery added
Returns:

  After the method is successfully executed, successCallback is called without any parameter. If an error occurs, errorCallback is called with errorCode and errorText.

See:
  Storage.removeApplication()