Skip to content
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

chore!: remove prefix resolver, passthrough prefix resolver, and accessLevel #4631

Merged
merged 81 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
40c7ec5
chore: add `StoragePath`
Jordan-Nelson Mar 11, 2024
ab28cb0
chore: add `S3PathResolver`
Jordan-Nelson Mar 11, 2024
f633918
chore: update `getUrl` and `getProperties` API
Jordan-Nelson Mar 11, 2024
584d156
chore: update S3UploadTask
Jordan-Nelson Mar 11, 2024
81ca9d5
chore: fix tests
Jordan-Nelson Mar 12, 2024
f66138e
chore: validate storage path
Jordan-Nelson Mar 12, 2024
94d2a9f
chore: add tests for S3PathResolver
Jordan-Nelson Mar 12, 2024
6ffbe91
feat: Gen 2 Upload APIs (#4542)
khatruong2009 Mar 13, 2024
d8843a5
chore: refactor StoragePath (#4544)
Jordan-Nelson Mar 13, 2024
4b693ee
chore: remove `key` from public APIs
Jordan-Nelson Mar 13, 2024
3a579de
chore: update tests to adjust for using path
khatruong2009 Mar 14, 2024
582ce73
chore: fix lint issues
Jordan-Nelson Mar 15, 2024
cb42a53
chore: fix formatting
Jordan-Nelson Mar 15, 2024
12b1738
chore: fix test
Jordan-Nelson Mar 15, 2024
8198346
chore: remove lint ignored
Jordan-Nelson Mar 15, 2024
b59c660
chore: update comment
Jordan-Nelson Mar 15, 2024
5abbf64
chore: remove unused method
Jordan-Nelson Mar 15, 2024
8e02c2f
chore: skip tests other than main
Jordan-Nelson Mar 15, 2024
5a924df
chore: update generated code
Jordan-Nelson Mar 18, 2024
0460d84
chore: add leading `/`
Jordan-Nelson Mar 18, 2024
d817f03
feat(storage): copy and move APIs (#4569)
Jordan-Nelson Mar 21, 2024
62ff206
chore: update download apis to use path (#4561)
khatruong2009 Mar 25, 2024
4f65c69
feat(storage): update `remove` and `removeMany` APIs (#4593)
Jordan-Nelson Mar 26, 2024
f284d55
chore: remove unused types and constructors, use consistent naming (…
Jordan-Nelson Mar 27, 2024
36ba0ad
feat: update list API (#4600)
khatruong2009 Mar 27, 2024
0687af6
chore(storage): cleanup and enable tests (#4617)
Jordan-Nelson Mar 28, 2024
0f6ef66
Update packages/storage/amplify_storage_s3/example/integration_test/u…
Jordan-Nelson Mar 28, 2024
1b5ab1e
chore: remove prefix resolver, passthrough prefix resolver, and acces…
khatruong2009 Apr 1, 2024
da413b0
chore: fix formatting and remove prefix in constructor
khatruong2009 Apr 1, 2024
de835d1
chore: remove StorageAccessLevel from s3pluginconfig and from amplify…
khatruong2009 Apr 1, 2024
adf0b01
chore: removed access level from cli config tests
khatruong2009 Apr 1, 2024
0e78edc
chore: add space back to test path
Jordan-Nelson Apr 2, 2024
17f1cfb
chore: update path in test
Jordan-Nelson Apr 2, 2024
0b071ef
Merge branch 'feat/storage-gen-2' into feat/storage-gen-2-remove-prefix
khatruong2009 Apr 8, 2024
fc906bb
chore: add `StoragePath`
Jordan-Nelson Mar 11, 2024
b100b26
chore: add `S3PathResolver`
Jordan-Nelson Mar 11, 2024
c729965
chore: update `getUrl` and `getProperties` API
Jordan-Nelson Mar 11, 2024
f738300
chore: update S3UploadTask
Jordan-Nelson Mar 11, 2024
2a91537
chore: fix tests
Jordan-Nelson Mar 12, 2024
d9fe4ef
chore: validate storage path
Jordan-Nelson Mar 12, 2024
d30a309
chore: add tests for S3PathResolver
Jordan-Nelson Mar 12, 2024
ff5f13d
feat: Gen 2 Upload APIs (#4542)
khatruong2009 Mar 13, 2024
adb8672
chore: refactor StoragePath (#4544)
Jordan-Nelson Mar 13, 2024
73810c8
chore: remove `key` from public APIs
Jordan-Nelson Mar 13, 2024
4f46a80
chore: update tests to adjust for using path
khatruong2009 Mar 14, 2024
f0cb5a2
chore: fix lint issues
Jordan-Nelson Mar 15, 2024
9918f95
chore: fix formatting
Jordan-Nelson Mar 15, 2024
3d0802f
chore: fix test
Jordan-Nelson Mar 15, 2024
4b9ffc2
chore: remove lint ignored
Jordan-Nelson Mar 15, 2024
ff67c0e
chore: update comment
Jordan-Nelson Mar 15, 2024
9b704d0
chore: remove unused method
Jordan-Nelson Mar 15, 2024
f5bb1cf
chore: skip tests other than main
Jordan-Nelson Mar 15, 2024
20026ec
chore: update generated code
Jordan-Nelson Mar 18, 2024
d150757
chore: add leading `/`
Jordan-Nelson Mar 18, 2024
fe28a87
feat(storage): copy and move APIs (#4569)
Jordan-Nelson Mar 21, 2024
cf1cd4a
chore: update download apis to use path (#4561)
khatruong2009 Mar 25, 2024
92f7ffc
feat(storage): update `remove` and `removeMany` APIs (#4593)
Jordan-Nelson Mar 26, 2024
734c3e8
chore: remove unused types and constructors, use consistent naming (…
Jordan-Nelson Mar 27, 2024
6379d5a
feat: update list API (#4600)
khatruong2009 Mar 27, 2024
c2c0b91
chore(storage): cleanup and enable tests (#4617)
Jordan-Nelson Mar 28, 2024
d1b8f54
Update packages/storage/amplify_storage_s3/example/integration_test/u…
Jordan-Nelson Mar 28, 2024
add05b0
chore: add space back to test path
Jordan-Nelson Apr 2, 2024
f277464
chore: update path in test
Jordan-Nelson Apr 2, 2024
3ce6292
chore: clean up example app
Jordan-Nelson Apr 3, 2024
8722cad
chore: rename `withIdentityId` to `fromIdentityId`
Jordan-Nelson Apr 3, 2024
d4c7677
chore: add validation for empty path
Jordan-Nelson Apr 3, 2024
4b516c1
chore: add tests for path resolver
Jordan-Nelson Apr 3, 2024
75dcdb7
chore: remove reference to CLI in doc comment
Jordan-Nelson Apr 3, 2024
ea79fb9
chore: add comment to `StoragePathFromIdentityId`
Jordan-Nelson Apr 3, 2024
c8cc621
chore: revert public API changes in s3 list result
Jordan-Nelson Apr 4, 2024
645218d
chore: use `resolvePaths` in copy API
Jordan-Nelson Apr 4, 2024
d479236
chore: update error handling for identityId
Jordan-Nelson Apr 9, 2024
9138e1e
chore: undo changes to type cast in html download file
Jordan-Nelson Apr 9, 2024
78886e0
chore: fix failing copy tests
Jordan-Nelson Apr 9, 2024
257e5bb
Merge branch 'feat/storage-gen-2' into feat/storage-gen-2-remove-prefix
khatruong2009 Apr 10, 2024
baea6fe
chore: remove prefix resolver caused by merge
khatruong2009 Apr 10, 2024
1b55c9d
chore: fix dart formatting errors
khatruong2009 Apr 10, 2024
14f2a33
chore: added comment to trigger tests
khatruong2009 Apr 10, 2024
6e335fa
chore: never mind
khatruong2009 Apr 10, 2024
f722a0a
chore: remove duplicated path resolver declaration
khatruong2009 Apr 10, 2024
171dbd2
Merge branch 'feat/storage-gen2' into feat/storage-gen-2-remove-prefix
khatruong2009 Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/amplify_core/lib/src/config/storage/s3_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class S3PluginConfig
const S3PluginConfig({
required this.bucket,
required this.region,
this.defaultAccessLevel = StorageAccessLevel.guest,
});

factory S3PluginConfig.fromJson(Map<String, Object?> json) =>
Expand All @@ -48,24 +47,20 @@ class S3PluginConfig

final String bucket;
final String region;
final StorageAccessLevel defaultAccessLevel;

@override
List<Object?> get props => [
bucket,
region,
defaultAccessLevel,
];

S3PluginConfig copyWith({
String? bucket,
String? region,
StorageAccessLevel? defaultAccessLevel,
}) {
return S3PluginConfig(
bucket: bucket ?? this.bucket,
region: region ?? this.region,
defaultAccessLevel: defaultAccessLevel ?? this.defaultAccessLevel,
);
}

Expand Down
11 changes: 0 additions & 11 deletions packages/amplify_core/lib/src/config/storage/s3_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions packages/amplify_core/lib/src/types/storage/access_level.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export '../exception/amplify_exception.dart'
StorageOperationCanceledException,
NetworkException,
UnknownException;
export 'access_level.dart';
export 'copy_operation.dart';
export 'copy_options.dart';
export 'copy_request.dart';
Expand Down
15 changes: 5 additions & 10 deletions packages/amplify_core/test/config/testdata/cli_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ const _v4storage = '''
"plugins": {
"awsS3StoragePlugin": {
"bucket": "$BUCKET",
"region": "$REGION",
"defaultAccessLevel": "guest"
"region": "$REGION"
}
}
}
Expand Down Expand Up @@ -379,8 +378,7 @@ const _v5storage = '''
"plugins": {
"awsS3StoragePlugin": {
"bucket": "$BUCKET",
"region": "$REGION",
"defaultAccessLevel": "guest"
"region": "$REGION"
}
}
}
Expand Down Expand Up @@ -567,8 +565,7 @@ const _v6storage = '''
"plugins": {
"awsS3StoragePlugin": {
"bucket": "$BUCKET",
"region": "$REGION",
"defaultAccessLevel": "guest"
"region": "$REGION"
}
}
}
Expand Down Expand Up @@ -755,8 +752,7 @@ const _v7storage = '''
"plugins": {
"awsS3StoragePlugin": {
"bucket": "$BUCKET",
"region": "$REGION",
"defaultAccessLevel": "guest"
"region": "$REGION"
}
}
}
Expand Down Expand Up @@ -943,8 +939,7 @@ const _vlateststorage = '''
"plugins": {
"awsS3StoragePlugin": {
"bucket": "$BUCKET",
"region": "$REGION",
"defaultAccessLevel": "guest"
"region": "$REGION"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@ import 'content_type_infer/content_type_infer.dart';
import 'transfer_acceleration/test_acceleration_config.dart';
import 'transfer_acceleration/transfer_acceleration.dart';

class CustomPrefixResolver implements S3PrefixResolver {
const CustomPrefixResolver();

@override
Future<String> resolvePrefix({
required StorageAccessLevel accessLevel,
String? identityId,
}) async {
final session = await Amplify.Auth.fetchAuthSession() as CognitoAuthSession;
final currentUserIdentityId = session.identityIdResult.value;
switch (accessLevel) {
case StorageAccessLevel.guest:
return 'everyone/';
case StorageAccessLevel.protected:
return 'shared/${identityId ?? currentUserIdentityId}/';
case StorageAccessLevel.private:
return 'private/$currentUserIdentityId/';
}
}
}

void main() {
// Disable Drift multi QueryExecutor warning as we know what's going on
// in this test suite
Expand Down Expand Up @@ -67,25 +46,19 @@ void main() {
for (final entry in amplifyEnvironments.entries
.where((element) => element.key != 'custom-prefix')) {
group('[Environment ${entry.key}]', () {
S3PrefixResolver? prefixResolver;
late String user1IdentityId;
late String object1Etag;
late String object2Etag;
late String object3Etag;
final shouldTestTransferAcceleration = entry.key != 'dots-in-name';

setUpAll(() async {
if (entry.key == 'custom-prefix') {
prefixResolver = const CustomPrefixResolver();
} else if (entry.key == 'no-prefix') {
prefixResolver = const PassThroughPrefixResolver();
}
final authPlugin = AmplifyAuthCognito(
secureStorageFactory: AmplifySecureStorage.factoryFrom(
macOSOptions: MacOSSecureStorageOptions(useDataProtection: false),
),
);
final storagePlugin = AmplifyStorageS3(prefixResolver: prefixResolver);
final storagePlugin = AmplifyStorageS3();
await Amplify.addPlugins([authPlugin, storagePlugin]);
await Amplify.configure(amplifyEnvironments[entry.key]!);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class AmplifyStorageS3 extends AmplifyStorageS3Dart {
/// {@macro amplify_storage_s3_.amplify_storage_s3_plugin}
AmplifyStorageS3({
super.delimiter,
super.prefixResolver,
});

/// A plugin key which can be used with `Amplify.Storage.getPlugin` to retrieve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ library amplify_storage_s3_dart;
export 'src/amplify_storage_s3_dart_impl.dart';
export 'src/error/invalid_bytes_range_error.dart';
export 'src/model/s3_models.dart';
export 'src/prefix_resolver/pass_through_prefix_resolver.dart';
export 'src/prefix_resolver/s3_prefix_resolver.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:amplify_storage_s3_dart/amplify_storage_s3_dart.dart';
import 'package:amplify_storage_s3_dart/src/path_resolver/s3_path_resolver.dart';
import 'package:amplify_storage_s3_dart/src/platform_impl/download_file/download_file.dart'
as download_file_impl;
import 'package:amplify_storage_s3_dart/src/prefix_resolver/storage_access_level_aware_prefix_resolver.dart';
import 'package:amplify_storage_s3_dart/src/storage_s3_service/storage_s3_service.dart';
import 'package:amplify_storage_s3_dart/src/storage_s3_service/transfer/transfer.dart'
as transfer;
Expand All @@ -32,10 +31,8 @@ class AmplifyStorageS3Dart extends StoragePluginInterface
/// {@macro amplify_storage_s3_dart.amplify_storage_s3_plugin_dart}
AmplifyStorageS3Dart({
String? delimiter,
S3PrefixResolver? prefixResolver,
@visibleForTesting DependencyManager? dependencyManagerOverride,
}) : _delimiter = delimiter,
_prefixResolver = prefixResolver,
_dependencyManagerOverride = dependencyManagerOverride;

/// {@template amplify_storage_s3_dart.plugin_key}
Expand All @@ -57,14 +54,8 @@ class AmplifyStorageS3Dart extends StoragePluginInterface
@protected
late final S3PluginConfig s3pluginConfig;

S3PrefixResolver? _prefixResolver;

late S3PathResolver _pathResolver;

/// Gets prefix resolver for testing
@visibleForTesting
S3PrefixResolver? get prefixResolver => _prefixResolver;

/// Gets the instance of dependent [StorageS3Service].
@protected
StorageS3Service get storageS3Service => dependencies.expect();
Expand Down Expand Up @@ -94,8 +85,7 @@ class AmplifyStorageS3Dart extends StoragePluginInterface
);
}

_prefixResolver ??= StorageAccessLevelAwarePrefixResolver(
delimiter: _delimiter,
_pathResolver = S3PathResolver(
khatruong2009 marked this conversation as resolved.
Show resolved Hide resolved
identityProvider: identityProvider,
);

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -557,32 +557,6 @@ class StorageS3Service {
.uri
.host;

/// Resolve a client object key to a "full" object key with proper prefix.
///
/// This API is only used internally.
@internal
static Future<String> getResolvedPrefix({
required S3PrefixResolver prefixResolver,
required AWSLogger logger,
required StorageAccessLevel accessLevel,
String? identityId,
}) async {
try {
return await prefixResolver.resolvePrefix(
accessLevel: accessLevel,
identityId: identityId,
);
} on Exception catch (error, st) {
logger.error('Error happened while resolving prefix', error, st);
throw UnknownException(
'An error occurred while resolving the prefix.',
recoverySuggestion:
'If you are providing a custom prefix resolver, review the underlying exception to determine the cause.',
underlyingException: error,
);
}
}

/// Creates and sends a [s3.HeadObjectRequest] to S3 service, and then
/// returns a [s3.HeadObjectOutput].
///
Expand Down