Lexicographical sorting with the "list" action

Lexicographical sorting is the ordering of objects based on the first path character that is different. When one path is a prefix of the other, the shorter path is first.

Objects are listed from the specified start [path]. When comparing characters the ASCII order is used. For example:

  • Numbers: Numbers are displayed alphabetically before alpha characters. In this example "10" comes before "2" due to the first character "1" being less than "2".
    • Example: 1, 10, 2, 21, 3
  • Alpha characters: Alphabetic sorting takes case sensitivity into consideration. Capitalized letters sort before lowercase.
    • Example: C, D, a, b
Note: The line numbers shown in the examples do not appear in the actual output. They are only for reference in the points that follow.

Example root-level list request

GET /[CP Code]/ HTTP/1.1 
Host: [Domain Prefix]-nsu.akamaihd.net 
X-Akamai-ACS-Action: version=1&action=list&format=xml

Example response

1  |  <list>  
2  |    <file type="file" name="[CP Code]/File11.ext" size="3" md5="[HASH]" mtime="1524068379"/> 
3  |    <file type="file" name="[CP Code]/File2.ext" size="3" md5="[HASH]" mtime="1524068382"/>  
4  |    <file type="dir"  name="[CP Code]/explicitdir1/"/>  
5  |    <file type="dir"  name="[CP Code]/explicitdir2/"/>  
6  |    <file type="file" name="[CP Code]/explicitdir2/File10.ext" size="3" md5="[HASH]" mtime="1524068475"/> 
7  |    <file type="file" name="[CP Code]/explicitdir2/implicit/File9.ext" size="3" md5="[HASH]" mtime="1524068475"/> 
8  |    <file type="symlink" name="[CP Code]/explicitdir2/link1"/>
9  |    <file type="file" name="[CP Code]/implicit/File3.ext" size="3" md5="[HASH]" mtime="1524068395"/>  
10 |    <file type="file" name="[CP Code]/implicit/File4.ext" size="3" md5="[HASH]" mtime="1524068407"/>  
11 |    <file type="file" name="[CP Code]/implicit/implicit2/File5.ext" size="3" md5="[HASH]" mtime="1524068405"/>  
12 |    <file type="file" name="[CP Code]/implicit/implicit2/File6.ext" size="3" md5="[HASH]" mtime="1524068410"/>  
13 |    <file type="file" name="[CP Code]/newFile.ext" size="3" md5="[HASH]" mtime="1524068411"/>  
14 |    <file type="file" name="[CP Code]/nextFile.ext" size="3" md5="[HASH]" mtime="1524068412"/>  
15 |  </list>
Explanation of response results
  • The results will start listing lexicographically from the specified start [path].
  • Implicit directories are not listed as directories. Instead, they are just in the file or symlink paths that use them. For example, if you used slashes in your filenames to incorporate implicit directories, they are shown as part of the file or symlink name.
  • Any explicit subdirectories in the target directory are listed next. They are shown as file type="dir". In the example above, lines 4 and 5 represent subdirectories in the target directory:
    • Line 4: <file type="dir" name="[CP Code]/explicitdir1/"/> This represents an empty explicit directory.
    • Line 5: <file type="dir" name="[CP Code]/explicitdir2/"/> This represents an explicit directory. The individual files and symlinks it contains are listed below it as a file type="[file/symlink]".
    Line 2: File11.ext comes before File2.ext because the first character after the filename prefix "File" is 1 and 2. Even though the number 11 is numerically higher than 2, the sorting is performed on a per-character basis lexicographically.
  • Lines 3-14: The list will traverse subdirectories lexicographically, resulting in objects being listed before and after subdirectories. For example, "newFile.ext" on line 13 is listed in the root path even though some root-level objects were previously shown on lines 2 and 3.

Example start-path list request

This example targets the "explicitdir2" directory as the start [path] (line 5 above) without limiting parameters as shown:

GET /[CP Code]/explicitdir2/ HTTP/1.1 
Host: [Domain Prefix]-nsu.akamaihd.net 
X-Akamai-ACS-Action: version=1&action=list&format=xml

Example response

1  |  <list>  
2  |    <file type="dir"  name="[CP Code]/explicitdir2/"/>  
3  |    <file type="file" name="[CP Code]/explicitdir2/File10.ext" size="3" md5="[HASH]" mtime="1524068475"/> 
4  |    <file type="file" name="[CP Code]/explicitdir2/implicit/File9.ext" size="3" md5="[HASH]" mtime="1524068475"/> 
5  |    <file type="symlink" name="[CP Code]/explicitdir2/link1"/>
6  |    <file type="file" name="[CP Code]/implicit/File3.ext" size="3" md5="[HASH]" mtime="1524068395"/>  
7  |    <file type="file" name="[CP Code]/implicit/File4.ext" size="3" md5="[HASH]" mtime="1524068407"/>  
8  |    <file type="file" name="[CP Code]/implicit/implicit2/File5.ext" size="3" md5="[HASH]" mtime="1524068405"/>
9  |    <file type="file" name="[CP Code]/implicit/implicit2/File6.ext" size="3" md5="[HASH]" mtime="1524068410"/>  
10 |    <file type="file" name="[CP Code]/newFile.ext" size="3" md5="[HASH]" mtime="1524068411"/>  
11 |    <resume start="[CP Code]/nextFile.ext"/>   
12 |  </list>
Explanation of response results
  • Line 2: The results will start listing from the specified start [path].
  • Lines 6-10: Remaining objects are listed recursively in lexicographic order until the end of the CP code, potentially outside of the specified start [path]. If this is undesirable see the end parameter or "dir" action.
  • Line 11: A resume start tag specifies the next path name to use when resuming the listing. This is a path, so it needs URL quoting before using it to make a request.

Limit results to a specific directory

Limit the results to a specified path by including a start [path] with end parameter.

Example request: Recursively list a single directory.

GET /[CP Code]/[path]/ HTTP/1.1 
Host: [Domain Prefix]-nsu.akamaihd.net 
X-Akamai-ACS-Action: version=1&action=list&format=xml&end=/[CP Code]/[path]0
[Signature Header 1]
[Signature Header 2]

Request

Here the request specifies a start [path] and end parameter.

GET /[CP Code]/explicitdir2/ HTTP/1.1 
Host: [Domain Prefix]-nsu.akamaihd.net 
X-Akamai-ACS-Action: version=1&action=list&format=xml&end=/[CP Code]/explicitdir2/link10

Response

1  |  <list>  
2  |    <file type="dir"  name="[CP Code]/explicitdir2/"/>  
3  |    <file type="file" name="[CP Code]/explicitdir2/File10.ext" size="3" md5="[HASH]" mtime="1524068475"/> 
4  |    <file type="file" name="[CP Code]/explicitdir2/implicit/File9.ext" size="3" md5="[HASH]" mtime="1524068475"/> 
5  |    <file type="symlink" name="[CP Code]/explicitdir2/link1"/>
6  |  </list>

Explanation of response results

  • Line 2: The listing begins from the specified start [path].
  • Line 4: The list recurses into the "implicit" directory.
  • Line 5: The listing stops on the specified end object, a symlink in this example.