Move files
You can move an existing file to a different folder location in your S3 bucket. The user initiating the move operation must have read and write permission on both the source file and destination file.
1import 'package:amplify_flutter/amplify_flutter.dart';2
3Future<void> movePrivateFile({4 required String sourceKey,5 required String destinationKey,6}) async {7 try {8 final result = await Amplify.Storage.move(9 source: StorageItemWithAccessLevel(10 storageItem: StorageItem(key: sourceKey),11 accessLevel: StorageAccessLevel.private,12 ),13 destination: StorageItemWithAccessLevel(14 storageItem: StorageItem(key: destinationKey),15 accessLevel: StorageAccessLevel.private,16 ),17 ).result;18
19 safePrint('Moved file to: ${result.movedItem.key}');20 } on StorageException catch (e) {21 safePrint('Something went wrong moving the file: ${e.message}');22 rethrow;23 }24}