gpt4 book ai didi

java - Amazon Elastic Transcoder - 如何使用名称获取预设

转载 作者:搜寻专家 更新时间:2023-11-01 02:58:07 27 4
gpt4 key购买 nike

我需要从列表 ( System Presets ) 中获取预设。如果我得到名称如下所示的预设,它将返回第一个预设。但我需要获取名称为“系统预设:通用 320x240”的 PresetId。

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();

上面的代码返回“1351620000001-000001”而不是“1351620000001-000061”

我的 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>

我正在尝试从 AWS Elastic Transcoder 获取所有预设,但以下代码仅返回 62 个中的 50 个

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

如何使用java动态获取Preset?如何获取所有预设(包括自定义预设)。

最佳答案

我更精通 Python SDK(而不是 Java 人),但这种行为看起来你只获得了 API 调用结果的第一页(50 个结果)——你需要实现分页才能获得所有结果.

调查

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.

参见 here

伪代码示例:对 listPresets() 的初始调用应获取 NextPageToken,然后继续迭代请求,直到 NextPageToken 为 null,同时将结果附加到局部变量。

关于java - Amazon Elastic Transcoder - 如何使用名称获取预设,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46564613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com