Queries the subdirectories or files in a specified directory of a General-purpose NAS file system.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListDirectoriesAndFiles

The operation that you want to perform.

Set the value to ListDirectoriesAndFiles.

FileSystemId String Yes 31a8e4****

The ID of the file system.

Path String Yes /pathway/to/folder

Specifies the absolute path of the directory.

The path must be prefixed by a forward slash (/). It must be a path that exists in the mount target.

NextToken String No TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=

The token that is used to initiate the next request if the response of the current request is truncated. You can use the token to initiate another request and obtain the remaining content.

StorageType String Yes InfrequentAccess

The storage type of the files.

Default value: InfrequentAccess (IA).

DirectoryOnly Boolean No false

Specifies whether to query only directories.

Default value: false. Valid values:

  • false: queries both directories and files.
  • true: queries only directories.
MaxResults Long No 100

The maximum number of directories or files to include in the results of each query.

Valid values: 10 to 128.

Default value: 100.

Response parameters

Parameter Type Example Description
NextToken String TGlzdFJlc291cmNlU****mVzJjE1MTI2NjY4NzY5MTAzOTEmMiZORnI4NDhVeEtrUT0=

The token that is used to initiate the next request if the response of the current request is truncated. You can use the token to initiate another request and obtain the remaining records.

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

The ID of the request.

Entries Array of Entry

The array of information about the files or directories.

Type String File

The type of the query result.

Valid values:

  • File
  • Directory
HasInfrequentAccessFile Boolean true

Indicates whether the files contain the data that is dumped to the IA storage medium.

The value of this parameter is returned and valid only if the value of the Type parameter is File.

Valid values:

  • true: The files contain data that is dumped to the IA storage medium.
  • false: The files do not contain data that is dumped to the IA storage medium.
Ctime String 2021-02-11T10:08:10Z

The time when the raw data was modified.

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

The value of this parameter is returned and valid only if the value of the Type parameter is File.

Mtime String 2021-02-11T10:08:08Z

The time when the file was last modified.

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

The value of this parameter is returned and valid only if the value of the Type parameter is File.

Size Long 1024

The size of the files.

Unit: bytes.

The value of this parameter is returned and valid only if the value of the Type parameter is File.

StorageType String InfrequentAccess

The storage type of the files.

The value of this parameter is returned and valid only if the value of the Type parameter is File.

Valid values:

  • standard: General-purpose NAS file system
  • InfrequentAccess: IA storage medium
Atime String 2021-02-01T10:08:08Z

The time range for the query.

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

The value of this parameter is returned and valid only if the value of the Type parameter is File.

Name String file.txt

The name of the files or directory.

RetrieveTime String 2021-02-11T10:08:08Z

The time when the last data retrieval job was run.

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

The value of this parameter is returned and valid only if the value of the Type parameter is File.

Inode String Inode

The file or directory inode.

FileId String 04***08

The ID of the directory or file.

Examples

Sample requests

http(s)://[Endpoint]/?Action=ListDirectoriesAndFiles
&FileSystemId=31a8e4****
&Path=/pathway/to/folder
&StorageType=InfrequentAccess
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<NextToken>aBcdeg==</NextToken>
<RequestId>BC7C825C-5F65-4B56-BEF6-98C56C7C****</RequestId>
<Entries>
    <Name>test.txt</Name>
    <Type>File</Type>
    <Inode>1000</Inode>
    <Size>20</Size>
    <Atime>2019-10-30T10:08:08Z</Atime>
    <Mtime>2019-10-30T10:08:08Z</Mtime>
    <CTime>2019-10-30T10:08:08Z</CTime>
    <RetrieveTime>2019-10-30T10:08:08Z</RetrieveTime>
    <StorageType>InfrequentAccess</StorageType>
</Entries>
<Entries>
    <Name>testDirectory</Name>
    <Type>Directory</Type>
    <Inode>1001</Inode>
    <HasInfrequentAccessFile>true</HasInfrequentAccessFile>
</Entries>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "NextToken" : "aBcdeg==",
  "RequestId" : "BC7C825C-5F65-4B56-BEF6-98C56C7C****",
  "Entries" : [ {
    "Name" : "test.txt",
    "Type" : "File",
    "Inode" : 1000,
    "Size" : 20,
    "Atime" : "2019-10-30T10:08:08Z",
    "Mtime" : "2019-10-30T10:08:08Z",
    "CTime" : "2019-10-30T10:08:08Z",
    "RetrieveTime" : "2019-10-30T10:08:08Z",
    "StorageType" : "InfrequentAccess"
  }, {
    "Name" : "testDirectory",
    "Type" : "Directory",
    "Inode" : 1001,
    "HasInfrequentAccessFile" : true
  } ]
}

Error codes

HttpCode Error code Error message Required
400 OperationDenied.InvalidNextToken The specified NextToken is invalid. The error message returned because the specified NextToken parameter is invalid.
404 InvalidFileSystem.NotFound The specified file system does not exist. The error message returned because the specified file system does not exist.
404 InvalidParameter.PathNotExist The specified path does not exist. The error message returned because the specified URL does not exist.

For a list of error codes, visit the API Error Center.