Remove files
To delete an object uploaded to S3, use Amplify.Storage.remove
.
With StoragePath
Amplify.Storage.remove( StoragePath.fromString("public/myUploadedFileName.txt"), result -> Log.i("MyAmplifyApp", "Successfully removed: " + result.getPath()), error -> Log.e("MyAmplifyApp", "Remove failure", error));
Amplify.Storage.remove(StoragePath.fromString("public/myUploadedFileName.txt"), { Log.i("MyAmplifyApp", "Successfully removed: ${it.path}") }, { Log.e("MyAmplifyApp", "Remove failure", it) })
try { val result = Amplify.Storage.remove(StoragePath.fromString("public/myUploadedFileName.txt")) Log.i("MyAmplifyApp", "Successfully removed: ${result.path}")} catch (error: StorageException) { Log.e("MyAmplifyApp", "Remove failure", error)}
RxAmplify.Storage.remove(StoragePath.fromString("public/myUploadedFileName.txt")) .subscribe( result -> Log.i("MyAmplifyApp", "Successfully removed: " + result.getPath()), error -> Log.e("MyAmplifyApp", "Remove failure", error) );
With Key (Deprecated)
Amplify.Storage.remove( "myUploadedFileName.txt", result -> Log.i("MyAmplifyApp", "Successfully removed: " + result.getKey()), error -> Log.e("MyAmplifyApp", "Remove failure", error));
Amplify.Storage.remove("myUploadedFileName.txt", { Log.i("MyAmplifyApp", "Successfully removed: ${it.key}") }, { Log.e("MyAmplifyApp", "Remove failure", it) })
try { val result = Amplify.Storage.remove("myUploadedFileName.txt") Log.i("MyAmplifyApp", "Successfully removed: ${result.key}")} catch (error: StorageException) { Log.e("MyAmplifyApp", "Remove failure", error)}
RxAmplify.Storage.remove("myUploadedFileName.txt") .subscribe( result -> Log.i("MyAmplifyApp", "Successfully removed: " + result.getKey()), error -> Log.e("MyAmplifyApp", "Remove failure", error) );