我尝试使用“TransferUtility”将文件上传到 AWS s3 存储桶,并且已在 Mobile HUB 上注册该应用程序,并将“awsconfiguration.json”文件粘贴到 res/raw 中,如文档中所述。
我得到了这个日志:
I/AWSMobileClient: Welcome to AWS! You are connected successfully.
当我在“onCreate()”中调用它时
AWSMobileClient.getInstance().initialize(this).execute();
执行此代码时出现此错误
TransferUtility transferUtility =
TransferUtility.builder()
.context(getApplicationContext())
.awsConfiguration(AWSMobileClient.getInstance().getConfiguration())
.s3Client(new AmazonS3Client(AWSMobileClient.getInstance().getCredentialsProvider()))
.build();
TransferObserver uploadObserver =
transferUtility.upload(
s3Bucket+"/"+s3Folder+"/"+fileName,
new File(fileUrl));
错误:
E/AndroidRuntime: FATAL EXCEPTION: main Process: xxxx.xxxxx.com, PID: 28698 java.lang.IllegalArgumentException: Failed to read S3TransferUtility please check your setup or awsconfiguration.json file at com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility$Builder.build(TransferUtility.java:248)
任何人都可以帮助我解决这个问题并指导我解决我在这里做错的事情吗?
我们非常感谢您的努力。谢谢
最佳答案
此错误意味着您有 awsconfiguration.json 文件,但 json 文件中可能没有 S3TransferUtility
block 。你能检查一下 json 文件中是否有所需的 block 吗?
关于java.lang.IllegalArgumentException : Failed to read S3TransferUtility please check your setup or awsconfiguration. json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49445164/