Search in sources :

Example 1 with ListItemsRequest

use of com.amazonaws.services.mediastoredata.model.ListItemsRequest in project aws-doc-sdk-examples by awsdocs.

the class ListItems method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "To run this example, supply the name of a container and an optional path!\n" + "\n" + "Ex: ListItems <container-name> [path]\n";
    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    final String containerName = args[0];
    String path = "";
    if (args.length > 1) {
        path = args[1];
    }
    System.out.format("Objects in MediaStore container %s, path '%s':\n", containerName, path);
    final String endpoint = getContainerEndpoint(containerName);
    if (endpoint == null || endpoint.isEmpty()) {
        System.err.println("Could not determine container endpoint!");
        System.exit(1);
    }
    final String region = new DefaultAwsRegionProviderChain().getRegion();
    final EndpointConfiguration endpointConfig = new EndpointConfiguration(endpoint, region);
    final AWSMediaStoreData mediastoredata = AWSMediaStoreDataClientBuilder.standard().withEndpointConfiguration(endpointConfig).build();
    final ListItemsRequest request = new ListItemsRequest().withPath(path);
    ListItemsResult result = mediastoredata.listItems(request);
    List<Item> items = result.getItems();
    for (Item i : items) {
        System.out.printf("* (%s)\t%s\n", i.getType(), i.getName());
    }
}
Also used : DefaultAwsRegionProviderChain(com.amazonaws.regions.DefaultAwsRegionProviderChain) Item(com.amazonaws.services.mediastoredata.model.Item) EndpointConfiguration(com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration) AWSMediaStoreData(com.amazonaws.services.mediastoredata.AWSMediaStoreData) ListItemsRequest(com.amazonaws.services.mediastoredata.model.ListItemsRequest) ListItemsResult(com.amazonaws.services.mediastoredata.model.ListItemsResult)

Aggregations

EndpointConfiguration (com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration)1 DefaultAwsRegionProviderChain (com.amazonaws.regions.DefaultAwsRegionProviderChain)1 AWSMediaStoreData (com.amazonaws.services.mediastoredata.AWSMediaStoreData)1 Item (com.amazonaws.services.mediastoredata.model.Item)1 ListItemsRequest (com.amazonaws.services.mediastoredata.model.ListItemsRequest)1 ListItemsResult (com.amazonaws.services.mediastoredata.model.ListItemsResult)1