【发布时间】:2016-02-12 05:15:32
【问题描述】:
我正在尝试从我在 Android 上的 Amazon S3 存储桶下载,但我收到了这个错误:
java.net.UnknownHostException: Unable to resolve host "cognito-identity.us-west-2.amazonaws.com": No address associated with hostname
在这一行
Download down = manager.download(AWSClientManager.S3_BUCKET_NAME, fileToDownload, file);
我不确定为什么当我的 CognitoCachingCredentialsProvider 的默认值为 us- 时它会使用 us-west-2东一号
即便如此,我的 s3 存储的以下位置具有完全相同的文件:
https://console.aws.amazon.com/s3/home?region=us-east-1
https://console.aws.amazon.com/s3/home?region=us-west-2
我不知道为什么会出现上述错误,有人可以帮忙吗?
嗨@马克, 我的 CognitoCachingCredentialsProvider 设置为 US_EAST_1
我正在使用 AmazonS3Client 下载 S3 文件。我认为这可能是问题所在。我明确设置了区域,尽管它似乎完全无视这一点。
这是我的错误代码:
private S3TaskResult downloadResources(String fileToDownload) {
S3TaskResult result = new S3TaskResult();
File file = new File(downloadDirectory, fileToDownload);
try {
manager.getAmazonS3Client().setRegion(com.amazonaws.regions.Region.getRegion(Regions.US_EAST_1));
Download down = manager.download(AWSClientManager.S3_BUCKET_NAME, fileToDownload, file);
down.addProgressListener(this);
down.waitForCompletion();
} catch (Exception e) {
// TODO: FIGURE OUT WHY IT ERRORS HERE :(
result.setErrorMessage(e.getMessage());
}
return result;
}
【问题讨论】:
-
fwiw:控制台区域在查看 S3 时没有传达任何有意义的信息,并且 us-west-2 没有 cognito identity endpoint 所以错误是准确的,尽管我意识到那是'没有太多的安慰——不清楚为什么你的代码试图使用 us-west-2。
-
感谢 Michael 的帮助,您提供的链接让我对 AWS 端点有了更深入的了解 :) 干杯
标签: android amazon-web-services amazon-s3 amazon-cognito