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

Page updated Aug 15, 2024

Remove files

Files can be removed from a storage bucket using the 'remove' API. If a file is protected by an identity Id, only the user who owns the file will be able to remove it.

You can also perform an upload operation to a specific bucket by providing the target bucket's assigned name from Amplify Backend in bucket option.

Alternatively, you can also pass in an object by specifying the bucket name and region from the console.

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