All Products
Search
Document Center

File Storage NAS:ListDirectoriesAndFiles

Last Updated:Jul 31, 2026

Retrieves the list of IA storage class files and subdirectories that contain IA storage class files under a specified directory in 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 file system ID.

31a8e4****

Path

string

Yes

The absolute path of the specified directory.

The path must start with a forward slash (/) and must be an existing path in the mount target.

/pathway/to/folder

NextToken

string

No

The pagination token that is used in the next request to retrieve a new page of results. If the return results are truncated, you can use NextToken to initiate a new request to retrieve the content after the current truncation position.

TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=

StorageType

string

Yes

The storage class type.

  • InfrequentAccess: IA storage class.

  • Archive: Archive storage class.

  • All: queries data of all storage classes.

Note

When StorageType is set to All, you must set DirectoryOnly to true.

Valid values:

  • All :

    Queries data of all storage classes.

  • Archive :

    Archive storage class.

  • InfrequentAccess :

    IA storage class.

InfrequentAccess

DirectoryOnly

boolean

No

Specifies whether to query only directories.

Valid values:

  • false (default): No. Both directories and files can be queried.

  • true: Yes. Only directories are queried.

Note

When StorageType is set to All, DirectoryOnly must be set to true and cannot be set to false.

false

MaxResults

integer

No

The number of directories or files included in each query result.

Valid values: 10 to 128.

Default value: 100.

100

Response elements

Element

Type

Description

Example

object

NextToken

string

The pagination token that is used in the next request to retrieve a new page of results. If the return results are truncated, you can use NextToken to initiate a new request to retrieve the content after the current truncation position.

TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=

RequestId

string

The request ID.

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

Entries

array<object>

The collection of directory or file information.

object

The collection of directory or file information.

Type

string

The type of the returned result.

Valid values:

  • File: file.

  • Directory: directory.

File

HasInfrequentAccessFile

boolean

Indicates whether the directory contains IA storage class files.

This parameter is returned and meaningful only when Type is set to Directory.

Valid values:

  • true: The directory contains IA storage class files.

  • false: The directory does not contain IA storage class files.

true

Ctime

string

The time when the metadata was modified.

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

This parameter is returned and meaningful only when Type is set to File.

2021-02-11T10:08:10Z

Mtime

string

The time when the file was modified.

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

This parameter is returned and meaningful only when Type is set to File.

2021-02-11T10:08:08Z

Size

integer

The size of the file.

Unit: bytes.

This parameter is returned and meaningful only when Type is set to File.

1024

StorageType

string

The storage class type of the returned file.

This parameter is returned and meaningful only when Type is set to File.

Valid values:

  • InfrequentAccess: IA storage class.

  • Archive: Archive storage class.

InfrequentAccess

Atime

string

The query time.

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

This parameter is returned and meaningful only when Type is set to File.

2021-02-01T10:08:08Z

Name

string

The file name or directory name.

file.txt

RetrieveTime

string

The time when the most recent data retrieval task was run.

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

This parameter is returned and meaningful only when Type is set to File.

2021-02-11T10:08:08Z

Inode

string

The inode of the file or directory.

66

FileId

string

The FileId of the directory or file.

66

Owner

string

The portable account ID. This parameter is meaningful only when ProtocolType is set to SMB and access control is enabled.

37862c****

HasArchiveFile

string

Indicates whether the directory contains archive storage class files.

This parameter is returned and meaningful only when Type is set to Directory.

Valid values:

  • true: The directory contains archive storage class files.

  • false: The directory does not contain archive storage class files.

true

OfflineDuration

integer

The total duration for which the file has been stored as an archive file. Unit: seconds.

3600

OfflineUnchangedDuration

integer

The total duration for which the file has remained unchanged since it was stored as an archive file. Unit: seconds.

3600

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": 3600,
      "OfflineUnchangedDuration": 3600
    }
  ]
}

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.