AmazonS3ClientBuilder 卡在构建函数上
AmazonS3ClientBuilder is stuck on build function
我正在使用亚马逊文档中建议的代码将文件上传到亚马逊存储桶。该代码在某些机器上是 运行,但在其他机器上,它不会通过 build() 行。
代码如下:
private static AWSBucketManager instance = null;
private final AmazonS3 s3;
private String clientRegion= Settings.getSettingValue("AWS_REGION");
private String secretKey = Settings.getSettingValue("AWS_SECRETKEY");
private String accesssKey = Settings.getSettingValue("AWS_ACCESSKEY");
private AWSBucketManager()
{
LoggingService.writeToLog("Login to aws bucket with basic creds",LogModule.Gateway, LogLevel.Info);
BasicAWSCredentials creds = new BasicAWSCredentials(accesssKey, secretKey);
LoggingService.writeToLog("Success Login to aws bucket with basic creds",LogModule.Gateway, LogLevel.Info);
s3 = AmazonS3ClientBuilder.standard()
.withRegion(clientRegion)
.withCredentials(new AWSStaticCredentialsProvider(creds))
.build();
LoggingService.writeToLog("Login successfully to aws bucket with basic creds",LogModule.Gateway, LogLevel.Info);
}
public static AWSBucketManager getInstance()
{
if(instance == null)
{
instance = new AWSBucketManager();
}
return instance;
}
知道出了什么问题吗?或者我如何使用日志对其进行调试?
出现问题是因为我的代码被 proguard 混淆了。
添加以下规则解决了这个问题:
-保持 class org.apache.commons.logging.** { *; }
-keepattributes 签名,注释
-保持 class com.amazonaws.** { *; }
我正在使用亚马逊文档中建议的代码将文件上传到亚马逊存储桶。该代码在某些机器上是 运行,但在其他机器上,它不会通过 build() 行。
代码如下:
private static AWSBucketManager instance = null;
private final AmazonS3 s3;
private String clientRegion= Settings.getSettingValue("AWS_REGION");
private String secretKey = Settings.getSettingValue("AWS_SECRETKEY");
private String accesssKey = Settings.getSettingValue("AWS_ACCESSKEY");
private AWSBucketManager()
{
LoggingService.writeToLog("Login to aws bucket with basic creds",LogModule.Gateway, LogLevel.Info);
BasicAWSCredentials creds = new BasicAWSCredentials(accesssKey, secretKey);
LoggingService.writeToLog("Success Login to aws bucket with basic creds",LogModule.Gateway, LogLevel.Info);
s3 = AmazonS3ClientBuilder.standard()
.withRegion(clientRegion)
.withCredentials(new AWSStaticCredentialsProvider(creds))
.build();
LoggingService.writeToLog("Login successfully to aws bucket with basic creds",LogModule.Gateway, LogLevel.Info);
}
public static AWSBucketManager getInstance()
{
if(instance == null)
{
instance = new AWSBucketManager();
}
return instance;
}
知道出了什么问题吗?或者我如何使用日志对其进行调试?
出现问题是因为我的代码被 proguard 混淆了。 添加以下规则解决了这个问题:
-保持 class org.apache.commons.logging.** { *; } -keepattributes 签名,注释
-保持 class com.amazonaws.** { *; }