Search code examples
androidamazon-web-servicesamazon-s3aws-amplifyaws-amplify-sdk-android

How to delete a file/object stored in an AWS S3 bucket, using the Android SDK?


I have searched the latest AWS docs for the Android SDK, on the official site. Unfortunately I couldn't find anything related to this. How can I delete a particular -- or multiple -- file(s) or object(s) using the Android SDK?


Solution

  • I have found a solution that works, if anyone comes looking it may help, did not find this in the docs of AWS for Android SDk, and the Amplify framework is in preview stage maybe it will come soon after few months. Till then the the solution is:

    new Thread(new Runnable() {
      @Override
      public void run() {
        s3Client.deleteObject(bucketName, filePath);
      }
    }).start();
    And always create a new thread or else it will throw error. Thank You