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

Page updated Nov 13, 2024

Copy files

Note: You can only copy files up to 5GB in a single operation

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

OptionTypeDescription
getPropertiesbooleanWhether 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,
),
),
);