use of software.amazon.awssdk.services.mediastoredata.model.MediaStoreDataException in project aws-doc-sdk-examples by awsdocs.
the class DeleteObject method deleteMediaObject.
// snippet-start:[mediastore.java2.delete_object.main]
public static void deleteMediaObject(MediaStoreDataClient mediaStoreData, String completePath) {
try {
DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder().path(completePath).build();
mediaStoreData.deleteObject(deleteObjectRequest);
} catch (MediaStoreDataException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.mediastoredata.model.MediaStoreDataException in project aws-doc-sdk-examples by awsdocs.
the class ListItems method listAllItems.
// snippet-start:[mediastore.java2.list_items.main]
public static void listAllItems(MediaStoreDataClient mediaStoreData, String completePath) {
try {
ListItemsRequest itemsRequest = ListItemsRequest.builder().path(completePath).build();
ListItemsResponse itemsResponse = mediaStoreData.listItems(itemsRequest);
Boolean hasItems = itemsResponse.hasItems();
if (hasItems) {
List<Item> items = itemsResponse.items();
for (Item item : items) {
System.out.println("Item name is: " + item.name());
System.out.println("Content type is: " + item.contentType());
}
} else {
System.out.println("There are no items");
}
} catch (MediaStoreDataException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.mediastoredata.model.MediaStoreDataException in project aws-doc-sdk-examples by awsdocs.
the class PutObject method putMediaObject.
// snippet-start:[mediastore.java2.put_object.main]
public static void putMediaObject(MediaStoreDataClient mediaStoreData, String filePath, String completePath) {
try {
File myFile = new File(filePath);
RequestBody requestBody = RequestBody.fromFile(myFile);
PutObjectRequest objectRequest = PutObjectRequest.builder().path(completePath).contentType("video/mp4").build();
PutObjectResponse response = mediaStoreData.putObject(objectRequest, requestBody);
System.out.println("The saved object is " + response.storageClass().toString());
} catch (MediaStoreDataException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.mediastoredata.model.MediaStoreDataException in project aws-doc-sdk-examples by awsdocs.
the class GetObject method getMediaObject.
// snippet-start:[mediastore.java2.get_object.main]
public static void getMediaObject(MediaStoreDataClient mediaStoreData, String completePath, String savePath) {
try {
GetObjectRequest objectRequest = GetObjectRequest.builder().path(completePath).build();
// Write out the data to a file.
ResponseInputStream<GetObjectResponse> data = mediaStoreData.getObject(objectRequest);
byte[] buffer = new byte[data.available()];
data.read(buffer);
File targetFile = new File(savePath);
OutputStream outStream = new FileOutputStream(targetFile);
outStream.write(buffer);
System.out.println("The data was written to " + savePath);
} catch (MediaStoreDataException | IOException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
Aggregations