I need to get the Preset from the List (System Presets). If I get the Preset with name like the following, it will returns the first Preset. But I need to get PresetId with name "System preset: Generic 320x240".
BasicAWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(creds)).build();
AmazonElasticTranscoder amazonElasticTranscoder = AmazonElasticTranscoderClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(creds)).withRegion(s3Client.getRegionName())
.build();
List<Preset> presets = amazonElasticTranscoder.listPresets().getPresets();
String presetId = presets.iterator().next().withName("System preset: Generic 320x240").getId();
The above code returns "1351620000001-000001" instead of "1351620000001-000061"
my pom.xml,
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.xxx.Application</start-class>
<java.version>1.8</java.version>
<aws.version>1.11.194</aws.version>
<aws.messaging.version>1.0.4</aws.messaging.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>${aws.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-elastictranscoder</artifactId>
<version>${aws.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>${aws.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
<version>${aws.messaging.version}</version>
</dependency>
I am trying to get the all Presets from AWS Elastic Transcoder but the following code returns only 50 out of 62
List<Preset> presets = amazonElasticTranscoder.listPresets().getPresets();
How to get the Preset dynamically using java? How to get all the Presets (include Custom presets) as well.
I am more versed in Python SDK (and not a Java person), but this behavior looks like you are getting only the first page (50 results) of the API call result - you need to implement paging to get all the results.
Look into
PageToken
When Elastic Transcoder returns more than one page of results, use PageToken in subsequent GET requests to get each successive page of results.
and
NextPageToken
A value that you use to access the second and subsequent pages of results, if any. When the presets fit on one page or when you've reached the last page of results, the value of NextPageToken is null.
See here
Pseudo-code Example: Initial call to listPresets() should get the NextPageToken, and then keep iterating the request until NextPageToken is null while appending results to a local variable.