Get Files 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
Endpoint URL¶
https://xxxx.backendless.app/api/files/<path>?
action=count&
pattern=<pattern>&
sub=<sub>&
countDirectories=<countDirectories>
where:
Argument | Description |
---|---|
<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¶
Important
Make sure to replace xxxx in the domain name in the sample requests below to the one assigned to your application.
Get a count of files matching the *.html
pattern in the /web
directory:
GET https://xxxx.backendless.app/api/files/web?action=count&pattern=*.html
Get a count of *.jpg
files in the /images
directory recursively :
GET https://xxxx.backendless.app/api/files/images?action=count&pattern=*.jpg&sub=true
Codeless Reference¶
where:
Argument | Description |
---|---|
path |
A path identifying a directory where files and folders must be counted. The path must start with the root directory of the remote file storage. |
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 counts files in all subdirectories. |
count directories |
If set to true , counts directories in addition to files. |
Returns the number of files and/or directories in the specified path.
Consider the following files stored in the days
directory:
The example below counts the number of files in the "days"
directory.
The result of this operation will look as shown below after the Codeless logic runs: