Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading files doesn't work with TransferUtility Amazon S3 in Android

Hi I have tried to upload a dummy textfile to Amazon S3. however it doesn't work but the log generated an id. When I refresh the Amazon S3 bucket dashboard. the file hasn't been transferred.

public class AmazonService extends AsyncTask<String, Boolean, Boolean> {
    Context mContext;
    public AmazonService(Context context) {
        mContext = context;
    }

    @Override
    protected Boolean doInBackground(String... params) {
        CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                mContext,
                "us-east-1:ec361bf5-52b9-477b-9a68-7e2b5f70de07", // Identity Pool ID
                Regions.US_EAST_1 // Region
        );
        AmazonS3Client client =
                new AmazonS3Client(credentialsProvider);
        TransferUtility transferUtility = new TransferUtility(client, mContext);
        TransferObserver observer = transferUtility.upload("elevator-app","Video/",new File("dummy.txt") );
        Log.d("Test", observer.getId() + " " + observer.getBytesTransferred());

        return true;
    }
}

//Service that is needed to have in AndroidManifest.xml

<service android:name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true" />
like image 464
Khiem-Kim Ho Xuan Avatar asked Sep 03 '15 19:09

Khiem-Kim Ho Xuan


1 Answers

I had the same problem, the reason was that I put the service tag outside the application tag. When I put the service tag inside the application tag everything worked perfectly.

like image 172
Malek Hijazi Avatar answered Sep 30 '22 23:09

Malek Hijazi