Search in sources :

Example 1 with AWSMediaStoreException

use of com.amazonaws.services.mediastore.model.AWSMediaStoreException 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 AWSMediaStoreException

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

the class PutObject method getContainerEndpoint.

public static String getContainerEndpoint(String name) {
    final AWSMediaStore mediastore = AWSMediaStoreClientBuilder.defaultClient();
    final DescribeContainerRequest request = new DescribeContainerRequest().withContainerName(name.trim());
    try {
        final DescribeContainerResult result = mediastore.describeContainer(request);
        return result.getContainer().getEndpoint();
    } catch (AWSMediaStoreException e) {
        System.err.println(e.getErrorMessage());
    }
    return null;
}
Also used : DescribeContainerRequest(com.amazonaws.services.mediastore.model.DescribeContainerRequest) DescribeContainerResult(com.amazonaws.services.mediastore.model.DescribeContainerResult) AWSMediaStore(com.amazonaws.services.mediastore.AWSMediaStore) AWSMediaStoreException(com.amazonaws.services.mediastore.model.AWSMediaStoreException)

Example 3 with AWSMediaStoreException

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

the class CreateContainer method createContainer.

public static Container createContainer(String name) {
    final AWSMediaStore mediastore = AWSMediaStoreClientBuilder.defaultClient();
    final CreateContainerRequest request = new CreateContainerRequest().withContainerName(name.trim());
    try {
        final CreateContainerResult result = mediastore.createContainer(request);
        return result.getContainer();
    } catch (AWSMediaStoreException e) {
        System.err.println(e.getErrorMessage());
    }
    return null;
}
Also used : CreateContainerRequest(com.amazonaws.services.mediastore.model.CreateContainerRequest) AWSMediaStore(com.amazonaws.services.mediastore.AWSMediaStore) AWSMediaStoreException(com.amazonaws.services.mediastore.model.AWSMediaStoreException) CreateContainerResult(com.amazonaws.services.mediastore.model.CreateContainerResult)

Example 4 with AWSMediaStoreException

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

the class ListItems method getContainerEndpoint.

public static String getContainerEndpoint(String name) {
    final AWSMediaStore mediastore = AWSMediaStoreClientBuilder.defaultClient();
    final DescribeContainerRequest request = new DescribeContainerRequest().withContainerName(name.trim());
    try {
        final DescribeContainerResult result = mediastore.describeContainer(request);
        return result.getContainer().getEndpoint();
    } catch (AWSMediaStoreException e) {
        System.err.println(e.getErrorMessage());
    }
    return null;
}
Also used : DescribeContainerRequest(com.amazonaws.services.mediastore.model.DescribeContainerRequest) DescribeContainerResult(com.amazonaws.services.mediastore.model.DescribeContainerResult) AWSMediaStore(com.amazonaws.services.mediastore.AWSMediaStore) AWSMediaStoreException(com.amazonaws.services.mediastore.model.AWSMediaStoreException)

Aggregations

AWSMediaStoreException (com.amazonaws.services.mediastore.model.AWSMediaStoreException)4 AWSMediaStore (com.amazonaws.services.mediastore.AWSMediaStore)3 DescribeContainerRequest (com.amazonaws.services.mediastore.model.DescribeContainerRequest)2 DescribeContainerResult (com.amazonaws.services.mediastore.model.DescribeContainerResult)2 EndpointConfiguration (com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration)1 DefaultAwsRegionProviderChain (com.amazonaws.regions.DefaultAwsRegionProviderChain)1 CreateContainerRequest (com.amazonaws.services.mediastore.model.CreateContainerRequest)1 CreateContainerResult (com.amazonaws.services.mediastore.model.CreateContainerResult)1 AWSMediaStoreData (com.amazonaws.services.mediastoredata.AWSMediaStoreData)1 PutObjectRequest (com.amazonaws.services.mediastoredata.model.PutObjectRequest)1