Files

Device Cloud stores files associated with a specific thing or associated with the organization of the thing (global).

Files identifiers are retrieved from Device Cloud using the file.put command and the file.get command. The file is then uploaded to Device Cloud using an HTTP POST command or retrieved from Device Cloud using an HTTP GET command. For more information about the commands, see file.put and file.get.

Tags are associated with files to help with filtering on the file display pages and have security tags associated with them to restrict access.

Access to files can be restricted to users and applications in the same the organization or allow access by users and applications in other organizations (public). 

Uploading files

To upload a file to Device Cloud do the following:

  1. Use the file.put command to send Device Cloud the file information and get a fileId in return.

  2. Use HTTP POST to upload the file to Device Cloud using the fileId obtained from the file.put command.

For example:

// file.put command is called:
{
  "cmd": {
    "command": "file.put",
    "params": {
      "fileName": "test_results.xls"
    }
  }
}

// file.put result:
{
  "cmd": {
    "success": true,
    "params": {devicecloud
      "fileId": "50000000000000000000042"
    }
  }
}

// Upload the file to Device Cloud through an HTTP POST in your programming environment. An example using curl is:
curl -x POST --data-binary @test_results.xls http://api.devicewise.com/file/50000000000000000000042 

In the above example, the base URL api.devicewise.com is the value on the Developer page, HTTP (or HTTPS) Endpoint.

Retrieving files

To retrieve a file from Device Cloud do the following:

  1. Use the file.get command to send Device Cloud the file information and get a fileId in return.

  2. Use HTTP GET to retrieve the file from Device Cloud using the fileId obtained from the file.get command.

For example:

// file.get command is called:
{
  "cmd": {
    "command": "file.get",
    "params": {
      "fileName": "test_results.xls",
      "global": true
    }
  }
}

// file.get result:
{
  "cmd": {
    "success": true,
    "params": {
      "fileId": "50000000000000000000042",
      "fileSize": 2824
    }
  }
}

// Download the file from Device Cloud via an HTTP GET in your programming environment. An example using curl is:
curl -o test_results.xls http://api.helixdevicecloud.com/file/50000000000000000000042 

In the above example, the base URL api.helixcevicecloud.com is the value from the Management Portal on the Developer page, HTTP (or HTTPS) Endpoint.