Skip to content

chore: flutter v2 storage fixes #7615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<InlineFilter filters={["swift", "android"]}>

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';
Expand Down
28 changes: 28 additions & 0 deletions src/fragments/lib-v1/storage/flutter/copy.mdx
Original file line number Diff line number Diff line change
@@ -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<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;
}
}
```
18 changes: 18 additions & 0 deletions src/fragments/lib-v1/storage/flutter/get-properties.mdx
Original file line number Diff line number Diff line change
@@ -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<void> 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;
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ import reactnative0 from '/src/fragments/lib-v1/storage/js/copy.mdx';

<Fragments fragments={{ 'react-native': reactnative0 }} />

import flutter0 from '/src/fragments/lib/storage/flutter/copy.mdx';
import flutter0 from '/src/fragments/lib-v1/storage/flutter/copy.mdx';

<Fragments fragments={{ flutter: flutter0 }} />
Original file line number Diff line number Diff line change
Expand Up @@ -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';

<Fragments fragments={{ flutter: flutter0 }} />
Loading