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

Page updated Apr 30, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

ファイルの削除

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