Amazon Elastic Transcoder - How to get a preset using a name

I need to get a preset from the list ( system presets ). If I get a preset with the name as shown below, it will return the first preset. But I need to get a PresetId named "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'm trying to get all presets from AWS Elastic Transcoder, but the following code only returns 50 of 62

List<Preset> presets = amazonElasticTranscoder.listPresets().getPresets();

How to get preset dynamically using java? How to get all presets (including user presets).

+4
source share
1 answer

SDK Python ( Java), , (50 ) API - , .

PageToken
When Elastic Transcoder returns more than one page of results, use PageToken in subsequent GET requests to get each successive page of results.

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.

: listPresets() NextPageToken, , NextPageToken null, .

+3

Source: https://habr.com/ru/post/1686876/


All Articles