Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated May 1, 2024

Remove files

The latest version of Amplify Storage supports specifying S3 objects as a paths.
We recommend using path instead of key to specify S3 objects.

Note: key parameter is deprecated and may be removed in next major version.

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