mercredi 4 mars 2015

Error while uploading file to Amazon S3 bucket

When I run my app and logins with google account, it gives me the cognito provider. Now I am trying to upload a file to S3 bucket from the app. First I am trying to upload a file from the app, then I will change it to upload from the app. Here is my code



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");}


This is what I get in my logs.



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


Now when I check the S3 bucket on AWS site, it doesn't show the file. There are no errors but the file is also not uploaded. It would be helpful if you can point out my mistake. Thanks.





Aucun commentaire:

Enregistrer un commentaire