Copy files
You can copy an existing file to a different path within the storage bucket using the copy API.
User who initiates a copy operation should have read permission on the copy source file.
Future<void> copy() async { try { final result = await Amplify.Storage.copy( source: const StoragePath.fromString('album/2024/1.jpg'), destination: const StoragePath.fromString('shared/2024/1.jpg'), ).result; safePrint('Copied file: ${result.copiedItem.path}'); } on StorageException catch (e) { safePrint(e); }}
More copy
options
Option | Type | Description |
---|---|---|
getProperties | boolean | Whether to retrieve properties for the copied object using theAmplify.Storage.getProperties() after the operation completes. When set to true the returned item will contain additional info such as metadata and content type. |
Example of copy
with options:
final result = Amplify.Storage.copy( source: const StoragePath.fromString('album/2024/1.jpg'), destination: const StoragePath.fromString('shared/2024/1.jpg'), options: const StorageCopyOptions( pluginOptions: S3CopyPluginOptions( getProperties: true, ), ),);