AWS Java S3 Uploading error: “profile file cannot be null”

半城伤御伤魂 提交于 2019-12-03 23:36:15

ProfileCredentialsProvider() creates a new profile credentials provider that returns the AWS security credentials configured for the default profile.

So, if you haven't any configuration for default profile at ~/.aws/credentials, while trying to put object, it yields that error.

If you run your code on Lambda service, it will not provide this file. In that case, you also do not need to provide credentials. Just assign right IAM Role to your lambda function, then using default constructor should solve issue.

You may want to change TransferManager constructor according to your needs.

The solution was pretty simple: I was trying to implement this communication without an AmazonS3 bean for Spring.

This link will help with the configuration:

http://codeomitted.com/upload-file-to-s3-with-spring/

my code worked fine as below:

AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(DefaultAWSCredentialsProviderChain.getInstance()).withRegion(clientRegion).build();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!