All Products
Search
Document Center

File Storage NAS:ListDirectoriesAndFiles

Last Updated:Apr 04, 2026

Lists Infrequent Access files and the subdirectories that contain them from a specified directory on a General-purpose NAS file system.

Operation description

Only general-purpose NAS file systems support this feature.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

nas:ListDirectoriesAndFiles

get

*FileSystem

acs:nas:{#regionId}:{#accountId}:filesystem/{#filesystemId}

None None

Request parameters

Parameter

Type

Required

Description

Example

FileSystemId

string

Yes

The ID of the file system.

31a8e4****

Path

string

Yes

The absolute path of the directory.

The path must start with a forward slash (/) and exist on the mount target.

/pathway/to/folder

NextToken

string

No

A continuation token used to retrieve the next page of results when the response is truncated.

TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=

StorageType

string

Yes

The storage type.

  • InfrequentAccess: infrequent access.

  • Archive: archive storage.

  • All: all storage types.

Note

If you set StorageType to All, you must set DirectoryOnly to true.

InfrequentAccess

DirectoryOnly

boolean

No

Whether to list only directories.

Valid values:

  • false (default): Lists both directories and files.

  • true: Lists only directories.

Note

If you set StorageType to All, you must set DirectoryOnly to true.

false

MaxResults

integer

No

The maximum number of directories or files to return per page.

Value range: 10–128

Default value: 100

100

Response elements

Element

Type

Description

Example

object

NextToken

string

The pagination token. If the response is truncated, include this token in the next request to retrieve the next page of results.

TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=

RequestId

string

The request ID.

2D69A58F-345C-4FDE-88E4-BF518948****

Entries

array<object>

The list of directory and file entries.

object

A directory or file entry.

Type

string

The type of the entry.

Valid values:

  • File: a file

  • Directory: a directory

File

HasInfrequentAccessFile

boolean

Specifies whether the directory contains any infrequent access files.

This parameter is returned only when Type is Directory.

Valid values:

  • true: Yes

  • false: No

true

Ctime

string

The metadata change time (ctime) of the file.

The time is in the ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ.

This parameter is returned only when Type is File.

2021-02-11T10:08:10Z

Mtime

string

The last modification time (mtime) of the file.

The time is in the ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ.

This parameter is returned only when Type is File.

2021-02-11T10:08:08Z

Size

integer

The size of the file, in bytes.

This parameter is returned only when Type is File.

This value is returned and is meaningful only when Type is File.

1024

StorageType

string

The storage class of the file.

This parameter is returned only when Type is File.

Valid values:

  • InfrequentAccess

  • Archive

InfrequentAccess

Atime

string

The last access time (atime) of the file.

The time is in the ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ.

This parameter is returned only when Type is File.

2021-02-01T10:08:08Z

Name

string

The name of the file or directory.

file.txt

RetrieveTime

string

The last data retrieval time.

The time is in the ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ.

This parameter is returned only when Type is File.

2021-02-11T10:08:08Z

Inode

string

The inode of the file or directory.

66

FileId

string

The ID of the file or directory.

66

Owner

string

The owner of the file or directory. This parameter is returned only when ProtocolType is SMB and access control is enabled.

37862c****

HasArchiveFile

string

Specifies whether the directory contains any archive files.

This parameter is returned only when Type is Directory.

Valid values:

  • true: Yes

  • false: No

true

OfflineDuration

integer

OfflineUnchangedDuration

integer

Examples

Success response

JSON format

{
  "NextToken": "TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=",
  "RequestId": "2D69A58F-345C-4FDE-88E4-BF518948****",
  "Entries": [
    {
      "Type": "File",
      "HasInfrequentAccessFile": true,
      "Ctime": "2021-02-11T10:08:10Z",
      "Mtime": "2021-02-11T10:08:08Z",
      "Size": 1024,
      "StorageType": "InfrequentAccess",
      "Atime": "2021-02-01T10:08:08Z",
      "Name": "file.txt",
      "RetrieveTime": "2021-02-11T10:08:08Z",
      "Inode": "66",
      "FileId": "66",
      "Owner": "37862c****",
      "HasArchiveFile": "true",
      "OfflineDuration": 0,
      "OfflineUnchangedDuration": 0
    }
  ]
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationDenied.InvalidNextToken The specified NextToken is invalid. The specified NextToken is invalid.
404 InvalidFileSystem.NotFound The specified file system does not exist. The specified file system does not exist.
404 InvalidParameter.PathNotExist The specified path does not exist. The specified path does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.