download free 30 days trial version buy bucket explorer
Documentation  Download  Purchase  Support  FAQs   Forum   ScreenShots & Demos

Amazon S3 - Listing Keys Hierarchically Using Prefix and Delimiter

Prefix and Delimiter parameters limit the kind of results returned by a list operation. Prefix limits the results to those keys only which begins with the specified prefix whereas delimiters tend to list all keys that shares a common prefix in a single summary list result.

You can list objects in hierarchy using Prefix and Delimiter by sending Http GET Bucket Request to Amazon S3, in one of the two below ways:

  1. List objects with Prefix and Delimiter using Amazon S3 REST API - "GET Bucket" within your software code : If you are a programmer, you can write your own code to list objects using Prefix and Delimiter with the help of AWS S3 REST or SOAP API. In this documentation, we are talking about the REST APIs only, you can refer to AWS S3 documentation for SOAP APIs.
  2. List objects with Prefix and Delimiter using Bucket Explorer : If you do not want to write code, you can easily list objects using Prefix and Delimiter with Bucket Explorer in few mouse clicks.

1. List Objects with Prefix and Delimiter using Amazon S3 REST API

To list some or all objects in a Bucket or to return a subset of the objects, you can request GET and use Prefix and Delimiter parameters and then browse your keys hierarchically.

Syntax


GET /?prefix=< prefixString > &delimiter=< delimiterString > HTTP/1.1
Host: < BucketName >.s3.amazonaws.com
Date: Wed, 01 Mar 2009 12:00:00 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:xQE0diMbLRepdf3YB+FIEXAMPLE=
 

In a single GET Bucket request, you get some or all (up to 1000) objects. In order to limit the results returned by the operation or to return a subset of the objects, you can use Request parameters as selection criteria such as Prefix and Delimeter. To authenticate the request, you must have READ access to the Bucket.

2. Search on Objects in a Bucket using Prefix and Delimeter with the help of Bucket Explorer

While the “GET Bucket” API allows you to get some or all of the objects in a Bucket and also allows you to limit the results returned by the operation using Prefix and Delimiter parameters by including and specifying the prefix and delimiter parameter in the code, Bucket Explorer lets you do that easily without the hassle of writing code.

You can Search by keywords to find or list objects which have that keyword in the file name. This is an advance search option provided in Object Table in Bucket Explorer. By providing only few keywords (prefix or delimiter or both), we can search for a particular object in long object listing. These keywords make your search more specific and accurate.

You can view the searched objects list in Full Path View as well as in Folder View by clicking on “Show Full Path” button in object toolbar. You can view your searched information below the object toolbar in this format “ Searched for prefix: photos/2006/ Delimiter: / Item Found: 3 ”. Search session continues until you refresh object list or bucket list.

Note: If you search with option Search By Prefix , you will see details in searched results like last modified date, etc. On the other hand, searching with option Prefix and Delimiter will not show you such object details like last modified date, etc.

 Steps to search objects in Bucket:

  1. Run Bucket Explorer.
  2. Click on Search button in object table toolbar.
  3. You will find two ways to search objects. These are Search By Prefix and Search By Prefix and Delimiter .
  4. A dialog box for search will appear according to the selected search option.
  5. If you are at any directory level and you click on Search button, then directory name is shown as non-editable text with suffix “/” in prefix text box.
  6. Now give some value in Prefix (starting character sequence of file or folder) text field OR in Delimiter (Ending character sequence of file or folder) text field OR in both and click on Search button.
  7. This will only give those folders and files that start with the given Prefix and end by Delimiter at root level. If any files and folders are in any folder, then search result will only show folders.
  8. On search result, if you explore any folder or directory OR back from any directory level up, then object list table will show objects according to your search criteria.

Prefix - The prefix can be anything from a partial string or single character up to the entire name of an object. Only objects with keys that start with the prefix will be listed. If object keys are divided into logical “directories” in your S3 account using forward-slashes (/), or indeed any character, only the contents of a “directory” can be displayed by using the directory name and the slash (e.g. “Documents/”).

Delimiter - Only objects with keys that match the prefix (if it is set) and end with the delimiter will be displayed. The delimiter is most useful when your object keys are divided into logical “directories” separated by a character such as forward-slash (/). In this case, specifying “/” as the delimiter will limit the object listing to only the top-level items or directories.

Search objects using Bucket Explorer

Example:

If you have a Bucket that contains the following keys:

photos/2006/index.html
photos/2006/img1001.jpg
photos/2006/January/img1001.jpg
...
photos/2006/January/img0999.jpg
photos/2006/February/img1000.jpg
photos/2006/March/img0001.html
...

Results:

  • A list query with Prefix="photos/2006/" and Delimiter="/" would return the keys and "subdirectories" at the photos/2006 level which starts with ="photos/2006/” and ended with “/” (as January, February,… are folders) but would not include any of the .jpg keys at deeper levels.
  • A list query with Prefix="photos/2006/" and Delimiter=".html" would return the keys and "subdirectories" at the photos/2006 level which starts with “photos/2006/” and ended with “.html” (index.html & March, April…..are subdirectories containing .html file(s)).
  • A list query with Prefix="photos/2006/" and Delimiter=".jpg" would return the keys and "subdirectories" at the photos/2006 level that starts with “photos/2006/” and ended with “.jpg” (img1001.jpg, January, February….are subdirectories contains that .jpg file(s)).

Note : As we search some objects, it will list the searched object at object table and a button “Switch to object list” will appear in object toolbar. Clicking on this button switches you to S3 object list from searched object list.