背景
公司有一套基于k8s的paas系统,现在pod中安装了aws 命令行工具
RUN apk add py-pip && pip install awscli
可以使用命令直接get、put文件,如下:

由于java使用命令行时可能会出现卡死现象,所以这里想使用aws提供的sdk来直接上传下载文件。
默认有两种方式,一种是程序中配置key:
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, awsSecretKey);
s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).withRegion(Regions.DEFAULT_REGION).build();
另外一种如下:
s3 = AmazonS3ClientBuilder.standard().withCredentials(new ProfileCredentialsProvider()).withRegion(Regions.DEFAULT_REGION).build();
报错
报错一:java.lang.IllegalArgumentException: profile file cannot be null
原因:

最低0.47元/天 解锁文章
729

被折叠的 条评论
为什么被折叠?



