Search in sources :

Example 1 with AWSMediaStoreData

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

the class PutObject method putObject.

public static PutObjectResult putObject(String containerName, String filePath, InputStream body) throws IOException {
    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 PutObjectRequest request = new PutObjectRequest().withContentType("application/octet-stream").withBody(body).withPath(filePath);
    try {
        return mediastoredata.putObject(request);
    } catch (AWSMediaStoreException e) {
        System.err.println(e.getErrorMessage());
        System.exit(1);
    }
    return null;
}
Also used : DefaultAwsRegionProviderChain(com.amazonaws.regions.DefaultAwsRegionProviderChain) EndpointConfiguration(com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration) AWSMediaStoreData(com.amazonaws.services.mediastoredata.AWSMediaStoreData) AWSMediaStoreException(com.amazonaws.services.mediastore.model.AWSMediaStoreException) PutObjectRequest(com.amazonaws.services.mediastoredata.model.PutObjectRequest)

Example 2 with AWSMediaStoreData

use of com.amazonaws.services.mediastoredata.AWSMediaStoreData 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)2 DefaultAwsRegionProviderChain (com.amazonaws.regions.DefaultAwsRegionProviderChain)2 AWSMediaStoreData (com.amazonaws.services.mediastoredata.AWSMediaStoreData)2 AWSMediaStoreException (com.amazonaws.services.mediastore.model.AWSMediaStoreException)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 PutObjectRequest (com.amazonaws.services.mediastoredata.model.PutObjectRequest)1