use of com.amazonaws.services.mediastoredata.model.PutObjectRequest 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;
}
Aggregations