无法从Android访问AWS S3

时间:2015-10-26 09:57:13

标签: android amazon-web-services amazon-s3

得到例外:

Unable to execute HTTP request: Unable to resolve host "cognito-identity.eu-central-1.amazonaws.com": No address associated with hostname
Unable to resolve host "cognito-identity.eu-central-1.amazonaws.com": No address associated with hostname

代码如下:

        // Initialize the Amazon Cognito credentials provider
        CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                getApplicationContext(), // Application Context
                getResources().getString(R.string.AWS_IdentityPoolId), // Identity Pool ID
                Regions.EU_CENTRAL_1 // Region enum
        );

2 个答案:

答案 0 :(得分:1)

这是地区的“公正”问题。由于我的Cognito位于爱尔兰,而我的Bucket位于Franckfurt,因此很容易混淆。所以你可能会小心区域。在可能的情况下:

// Initialize the Amazon Cognito credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
       getApplicationContext(), // Application Context
       getResources().getString(R.string.AWS_IdentityPoolId), // Identity Pool ID
       Regions.EU_WEST_1 // Region enum
);

答案 1 :(得分:1)

仅供参考,尚未在EU_CENTRAL_1(法兰克福)提供Cognito Identity。结帐AWS Service Region Availability。就像安东尼所说,Cognito Identity不必与其他服务处于同一区域。请始终选择离您最近的地区以获得更好的体验。