Skip to content

Get File Count

This operation returns the number of files and optionally directories located in the specified path. Additional options include:

  • pattern filtering - counts files and directories which match the pattern.
  • recursive counting - when enabled, counts all matching files and directories while recursively traversing the directory structure.

Method

GET

URL

https://api.backendless.com/<application-id>/<REST-api-key>/files/<path>?  
                    action=count&  
                    pattern=<pattern>&  
                    sub=<sub>&  
                    countDirectories=<countDirectories>

where:

Argument                Description
<application id> ID of the application which can be obtained from the Manage > App Settings screen of the Backendless Console
<REST-api-key> REST API key of your application. You can get the value from the Manage > App Settings section of the Backendless Console.
<path> path of a directory to calculate the count for.
<pattern> an optional parameter. A pattern which the counted files and optionally directories (if the sub parameter is set to true) must match. Backendless supports two formats for pattern: glob and regular expressions. You can specify the pattern matching format to use with a prefix as shown below:
pattern=glob:profilepic*.png or pattern=regex:pic[0-9]\.png. If the prefix format is not specified, Backendless treats the pattern as glob.
<sub> an optional parameter. A boolean value of true or false. If present and is true, requests that the count must recursively include all directories contained within <path>.
<countDirectories> an optional parameter. A boolean value of true or false. If present and is true, directories should be included into the count.

Request headers

user-token: optional value obtained as a result of the login operation.

where:

Argument                Description
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request Body:

None.

where:

Argument                Description
path path of a directory in the Backendless files storage starting with /
pattern a pattern which the counted files and optionally directories (if the recursive parameter is set to true) must match. Backendless supports two formats for pattern: glob and regular expressions. You can specify the pattern matching format to use with a prefix as shown below:
glob:profilepic*.png or regex:pic[0-9]\.png. If the prefix format is not specified, Backendless treats the pattern as glob.
recursive if set to true, recursively count matching files in all subdirectories.
countDirectories if set to true, count directories in addition to files.

Example

Get a count of files matching the *.html pattern in the /web directory:

GET https://api.backendless.com/<application-id>/<REST-api-key>/files/web?action=count

Get a count of *.jpg files in the /images directory recursively :

GET https://api.backendless.com/<application-id>/<REST-api-key>/files/images?action=count&pattern=*.jpg&sub=true