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

Page updated May 21, 2024

Copy files

Amplify Flutter v1 is now in Maintenance Mode until April 30th, 2025. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

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.

You can copy an existing file to a different location in your S3 bucket. User who initiates a copy operation should have read permission on the copy source file.

import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> copy({
required String sourceKey,
required String destinationKey,
}) async {
try {
final result = await Amplify.Storage.copy(
source: StorageItemWithAccessLevel(
storageItem: StorageItem(key: sourceKey),
accessLevel: StorageAccessLevel.guest,
),
destination: StorageItemWithAccessLevel(
storageItem: StorageItem(key: destinationKey),
accessLevel: StorageAccessLevel.private,
),
).result;
safePrint('Copied file: ${result.copiedItem.key}');
} on StorageException catch (e) {
safePrint('Error copying file: ${e.message}');
rethrow;
}
}