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

Page updated Apr 29, 2024

Remove files

Amplify Flutter v1 is deprecated as of April 30th, 2025. No new features or bug fixes will be added. Dependencies may become outdated and potentially introduce compatibility issues.

Please use the latest version (v2) of Amplify Flutter to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

Remove a file

You can remove a single file using Amplify.Storage.remove with the key and its associated access level:

import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> removeFile({
required String key,
required StorageAccessLevel accessLevel,
}) async {
try {
final result = await Amplify.Storage.remove(
key: key,
options: StorageRemoveOptions(
accessLevel: accessLevel,
),
).result;
safePrint('Removed file: ${result.removedItem.key}');
} on StorageException catch (e) {
safePrint('Error deleting file: ${e.message}');
rethrow;
}
}

Remove multiple files

You can remove multiple files using Amplify.Storage.removeMany with the keys, the files to be removed in a batch should have the same access level:

import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> removePrivateFiles({
required List<String> keys,
}) async {
try {
final result = await Amplify.Storage.removeMany(
keys: keys,
options: const StorageRemoveManyOptions(
accessLevel: StorageAccessLevel.private,
),
).result;
safePrint('Removed files: ${result.removedItems}');
} on StorageException catch (e) {
safePrint('Error deleting files: ${e.message}');
rethrow;
}
}