Closed patelnirav48 closed 2 years ago
Hi, can you provide some more information to help us identify the issue? Specifically, if you can provide a sample of the code you're running that will reproduce the issue and your configuration with any sensitive information removed that would be helpful.
1) Using below method to configure amplify
void _initAmplifyFlutter() async {
AmplifyAuthCognito auth = AmplifyAuthCognito();
AmplifyStorageS3 storage = AmplifyStorageS3();
Amplify.addPlugins([auth, storage]);
//Initialize AmplifyFlutter
try {
await Amplify.configure(amplifyconfig);
print("Amplify was configured.");
} on AmplifyAlreadyConfiguredException {
print("Amplify was already configured. Looks like app restarted on android.");
}
}
2) Below code to upload to storage
FilePickerResult? pickResult =
await FilePicker.platform.pickFiles(type: FileType.image);
if (pickResult == null) {
print('User canceled upload.');
return;
}
File file = File(pickResult.files.single.path!);
// Upload image with the current time as the key
final key = new DateTime.now().toString();
Map<String, String> metadata = <String, String>{};
metadata['name'] = 'filename';
metadata['desc'] = 'A test file';
S3UploadFileOptions options = S3UploadFileOptions(
accessLevel: StorageAccessLevel.guest, metadata: metadata);
// Upload the file to S3 with options
try {
final UploadFileResult result = await Amplify.Storage.uploadFile(
local: file,
key: key,
options: options,
onProgress: (progress) {
print("Fraction completed: " + progress.getFractionCompleted().toString());
}
);
print('Successfully uploaded file: ${result.key}');
} on StorageException catch (e) {
print('Error uploading file: $e');
}
3) amplifyconfiguration.dart file, when i did amplify init command its contain only UserAgent, version
const amplifyconfig = ''' {
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"UserAgent": "aws-amplify-cli/0.1.0",
"Version": "0.1.0",
"IdentityManager": {
"Default": {}
},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "us-east-1:*********",
"Region": "us-east-1"
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId": "us-east-1_*********",
"AppClientId": "*********",
"AppClientSecret": "*********",
"Region": "us-east-1"
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH"
}
},
"S3TransferUtility": {
"Default": {
"Bucket": "qa-*********-bucket",
"Region": "us-east-1"
}
}
}
}
},
"storage": {
"plugins": {
"awsS3StoragePlugin": {
"bucket": "qa-*********-bucket",
"region": "us-east-1",
"defaultAccessLevel": "guest"
}
}
}
}''';
@patelnirav48 - What version of Amplify-Flutter are you using? Can you give an output of running flutter pub deps --no-dev --style=compact
in your project?
Hi @patelnirav48
I am closing this issue for now as we didn't hear from you We can reopen it if you are still facing the issue and when you provide the details
Regards Mo
Describe the bug
// // Copyright Amazon.com Inc. or its affiliates. // All Rights Reserved. // // SPDX-License-Identifier: Apache-2.0 //
import Foundation
/// Amplify error raised in the Auth category. public enum AuthError {
}
extension AuthError: AmplifyError {
}
Steps To Reproduce
Expected behavior
Should allow to upload image to aws s3
Amplify Framework Version
0.2.10
Amplify Categories
Storage
Dependency manager
Cocoapods
Swift version
5.0
CLI version
7.6.7
Xcode version
13.1
Relevant log output
No response
Is this a regression?
No
Regression additional context
No response
Device
iPhone 8 Plus
iOS Version
iOS 15
Specific to simulators
No response
Additional context
No response