diff --git a/src/fragments/lib-v1/datastore/native_common/getting-started.mdx b/src/fragments/lib-v1/datastore/native_common/getting-started.mdx index c8651d3ca13..1601abb75a8 100644 --- a/src/fragments/lib-v1/datastore/native_common/getting-started.mdx +++ b/src/fragments/lib-v1/datastore/native_common/getting-started.mdx @@ -99,10 +99,10 @@ enum PostStatus { Now you will to convert the platform-agnostic `schema.graphql` into platform-specific data structures. DataStore relies on code generation to guarantee schemas are correctly converted to platform code. -Like the initial setup, models can be generated either using the IDE integration or Amplify CLI directly. - +Like the initial setup, models can be generated either using the IDE integration or Amplify CLI directly. + ### Code generation: Platform integration import ios12 from '/src/fragments/lib-v1/datastore/ios/getting-started/40_codegen.mdx'; diff --git a/src/fragments/lib-v1/storage/flutter/copy.mdx b/src/fragments/lib-v1/storage/flutter/copy.mdx new file mode 100644 index 00000000000..0b603a8f400 --- /dev/null +++ b/src/fragments/lib-v1/storage/flutter/copy.mdx @@ -0,0 +1,28 @@ +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. + +```dart +import 'package:amplify_flutter/amplify_flutter.dart'; + +Future 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; + } +} +``` diff --git a/src/fragments/lib-v1/storage/flutter/get-properties.mdx b/src/fragments/lib-v1/storage/flutter/get-properties.mdx new file mode 100644 index 00000000000..a2d601a3778 --- /dev/null +++ b/src/fragments/lib-v1/storage/flutter/get-properties.mdx @@ -0,0 +1,18 @@ +You can get file properties and metadata without downloading the file using `Amplify.Storage.getProperties`. + +```dart +import 'package:amplify_flutter/amplify_flutter.dart'; + +Future getFileProperties() async { + try { + final result = await Amplify.Storage.getProperties( + key: 'example.txt', + ).result; + + safePrint('File size: ${result.storageItem.size}'); + } on StorageException catch (e) { + safePrint('Could not retrieve properties: ${e.message}'); + rethrow; + } +} +``` diff --git a/src/pages/gen1/[platform]/prev/build-a-backend/storage/copy/index.mdx b/src/pages/gen1/[platform]/prev/build-a-backend/storage/copy/index.mdx index cd87d4d4d1e..c426c514fb5 100644 --- a/src/pages/gen1/[platform]/prev/build-a-backend/storage/copy/index.mdx +++ b/src/pages/gen1/[platform]/prev/build-a-backend/storage/copy/index.mdx @@ -60,6 +60,6 @@ import reactnative0 from '/src/fragments/lib-v1/storage/js/copy.mdx'; -import flutter0 from '/src/fragments/lib/storage/flutter/copy.mdx'; +import flutter0 from '/src/fragments/lib-v1/storage/flutter/copy.mdx'; diff --git a/src/pages/gen1/[platform]/prev/build-a-backend/storage/get-properties/index.mdx b/src/pages/gen1/[platform]/prev/build-a-backend/storage/get-properties/index.mdx index 50ed7db5495..2f69e336b04 100644 --- a/src/pages/gen1/[platform]/prev/build-a-backend/storage/get-properties/index.mdx +++ b/src/pages/gen1/[platform]/prev/build-a-backend/storage/get-properties/index.mdx @@ -55,6 +55,6 @@ import js0 from '/src/fragments/lib-v1/storage/js/get-properties.mdx'; }} /> -import flutter0 from '/src/fragments/lib/storage/flutter/get-properties.mdx'; +import flutter0 from '/src/fragments/lib-v1/storage/flutter/get-properties.mdx';