当我运行我的应用程序并使用谷歌帐户登录时,它给了我认知提供者。现在我正在尝试从应用程序将文件上传到 S3 存储桶。首先,我尝试从本地笔记本电脑上传文件,然后将其更改为从应用程序上传。这是我的代码
provider = new CognitoCachingCredentialsProvider(mContext,
AWS_ACCOUNT_ID, IDENTITY_POOL_ID, UNAUTH_ROLE_ARN, AUTH_ROLE_ARN,Regions.EU_WEST_1);
client = new CognitoSyncManager(mContext, IDENTITY_POOL_ID, Regions.EU_WEST_1, provider);
String BUCKET_NAME = "uni-cloud";
String access_key = "something";
TransferManager transferManager = new TransferManager(provider);
File file = new File("E:\\Google Drive\\Year 3\\Project\\dummy.docx");
Log.e("Cognito Provider ID","Data " + provider.getIdentityId());
try {
Upload upload = transferManager.upload(BUCKET_NAME,access_key, file);
while (!upload.isDone()){
Log.i("upload","Uploading");
}
Log.i("upload","Uploaded");
}catch(Exception e) {Log.i("Upload", "Error while uploading");}
这是我在日志中得到的。
03-04 17:27:57.789 24584-24712/com.unicloud.mittal I/upload﹕ Uploading
03-04 17:27:57.789 24584-24712/com.unicloud.mittal I/upload﹕ Uploading
03-04 17:27:57.799 24584-24712/com.unicloud.mittal I/upload﹕ Uploaded
现在,当我在 AWS 站点上检查 S3 存储桶时,它没有显示该文件。没有错误,但文件也没有上传。如果您能指出我的错误,那将很有帮助。谢谢。