Search in sources :

Example 1 with RequestBody

use of software.amazon.awssdk.core.sync.RequestBody 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);
    }
}
Also used : MediaStoreDataException(software.amazon.awssdk.services.mediastoredata.model.MediaStoreDataException) PutObjectResponse(software.amazon.awssdk.services.mediastoredata.model.PutObjectResponse) File(java.io.File) PutObjectRequest(software.amazon.awssdk.services.mediastoredata.model.PutObjectRequest) RequestBody(software.amazon.awssdk.core.sync.RequestBody)

Aggregations

File (java.io.File)1 RequestBody (software.amazon.awssdk.core.sync.RequestBody)1 MediaStoreDataException (software.amazon.awssdk.services.mediastoredata.model.MediaStoreDataException)1 PutObjectRequest (software.amazon.awssdk.services.mediastoredata.model.PutObjectRequest)1 PutObjectResponse (software.amazon.awssdk.services.mediastoredata.model.PutObjectResponse)1