file.list

The file.list command is used to find and return a list of files associated to a Thing (Files)or an OrgFiles

TR50 Request

{
  "cmd": {
    "command": "file.list",
    "params": {
      "global": true, 
      "sort":"+uploadDate", 
      "limit": 2, 
      "tags": ["tag1", "tag2"],
      "thingKey": "359180083486388" 
    }
  }
}

Request Parameters

Name

Type Required

Description

thingKey String   Thing key of the Thing that contains the files. Defaults to the current session's Thing.
global Boolean   If set to true, only global files are listed. The thingKey will be ignored.
If this request is made by a thing, the thingKey of the thing will be used. If this command is not issued by a thing, either thingKey or global must be specified.
tags Array   If specified, the command will only return results that possess all of these tags.
offset Integer   The starting list offset, used for pagination. Defaults to 0 if not specified.
limit Integer   Limits the number of results returned. The maximum you can set is 2000. Defaults to 2000.
sort String sort is an optional parameter that defines the sort order of the result set. It allows to arrange the list in either ascending(+) or descending(-) order. It is possible to sort file.list in the following categories:
  • uploadDate 
  • fileName (default)
  • length
  • public

TR50 Response

If the command is sent successfully a success message is returned. Otherwise, an error and error message will be returned.

{
  "cmd": {
    "success": true,
    "params": {
      "result": [
        {
          "id": "536adfdb3100461c910041a4",
          "uploadDate": "2019-08-16T14:28:12.05Z",
          "fileName": "MyTestFile.txt",
          "length": 3030,
          "public": true,
          "tags": [
            "txt"
          ]
        },
        {
          "id": "536ae07d3100461c9100420a",
          "uploadDate": "2019-08-16T14:28:36.103Z",
          "fileName": "MySecureTestFile.txt",
          "length": 75385,
          "tags": [
            "txt"
          ]
        }
      ]
    }
  }
}

Response Parameters

Name
Type
Description
count Integer The total number of matching results.
result Array An array consisting of result objects.
private Boolean Whether the file requires an authentication token to access.

Result Object

Name Type Description
id String The unique identifier of the file.
uploadDate String The timestamp associated with the creation of this file.
fileName String The name of the file.
public Boolean Whether the file is publicly accessible.
length Integer The size of the file in bytes.
tags Array The tags associated with the file.
username string If Basic Access Authentication is enabled for a file, the username to download the file will be returned. The corresponding password will not be returned.