```dart import 'package:amplify_flutter/amplify_flutter.dart'; import 'package:amplify_storage_s3/amplify_storage_s3.dart'; Future downloadProtectedFile({ required String key, required String targetIdentityId, required String downloadPath, }) async { final awsFile = AWSFile.fromPath(downloadPath); final options = StorageDownloadFileOptions( // specify that the file has a protected access level accessLevel: StorageAccessLevel.protected, // specify the identity ID of the user who uploaded this file pluginOptions: S3DownloadFilePluginOptions.forIdentity( targetIdentityId, ), ); try { final result = await Amplify.Storage.downloadFile( key: key, localFile: awsFile, options: options, ).result; safePrint('Downloaded file is located at: ${result.localFile.path}'); } on StorageException catch (e) { safePrint('Something went wrong downloading the file: ${e.message}'); rethrow; } } ```