aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 242 forks source link

Amplify.Storage.uploadFile Error #3126

Closed hailuongsl97 closed 11 months ago

hailuongsl97 commented 1 year ago

Description

I upload image from mobile to s3 and the problem occurs as below

_UnknownException (UnknownException {
  "message": "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": "InvalidAccountTypeException {\n  \"message\": \"No identity pool registered for this account\",\n  \"recoverySuggestion\": \"Register an identity pool using the CLI\"\n}"
})_

please help me to solve the problem sdk: ^3.0.0 flutter: 3.10.0

Amplify

amplify_flutter: ^1.1.0 amplify_datastore: amplify_api: ^1.1.0 amplify_auth_cognito: ^1.1.0 amplify_storage_s3: ^1.1.0 Screenshot 2023-06-01 at 16 24 27

Categories

Steps to Reproduce

No response

Screenshots

No response

Platforms

Flutter Version

3.10.0

Amplify Flutter Version

1.1.0

Deployment Method

Amplify CLI

Schema

No response

Equartey commented 1 year ago

Hey @hailuongsl97

Looks like there is an issue with the Auth plugin configuration. If you're using a custom config file, please ensure it matches the generated file template.

Can you share your amplify config (you can remove any sensitive or app specific info such as API keys or app IDs)?

hailuongsl97 commented 1 year ago

Looks like there is an issue with the Auth plugin configuration. If you're using a custom config file, please ensure it matches the generated file template.

Can you share your amplify config (you can remove any sensitive or app specific info such as API keys or app IDs)?

everything still works in flutter 2.5 but when i update to version 3.10.0 and s3 v1.1.0 get above problem

Equartey commented 1 year ago

@hailuongsl97

Understood, I'm sorry this issue came up while upgrading versions.

I need more context of your setup to help you further. Can you share your amplify config (minus the sensitive data)?

Jordan-Nelson commented 1 year ago

Hi @hailuongsl97 - If you are still facing this issue can you please provide your amplify config (you can remove any sensitive or app specific info such as API keys or app IDs) and the code snippet where you call Amplify.confifure()?

Do you have an identity pool? Are you attempting to use a custom resolver?

bjmcallister commented 1 year ago

@Jordan-Nelson I'm having the exact same issue after updating. It has to be something with the configuration file, but I'm unable to recreate my configuration file for whatever reason. Below is it.

Everything works except uploadfile.

    if (!Amplify.isConfigured) {
      try {
        // Add the followaing line to add Auth plugin to your app.
        await Amplify.addPlugins([
          AmplifyAPI(),
          AmplifyAuthCognito(),
          AmplifyStorageS3(),
          // AmplifyAnalyticsPinpoint()
        ]);

        // call Amplify.configure to use the initialized categories in your app
        try {
          await Amplify.configure(amplifyconfig);
          print('Amplify configured');
        } catch (e) {
          print(e);
        }

        setState(() {
          isLoading = false;
        });

        return true;
      } on Exception catch (e) {
        print('An error occurred configuring Amplify: $e');
        return false;
      }
    }

    setState(() {
      isLoading = false;
    });
    return true;
  }
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": “hidden”,
                            "Region": "us-east-1"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "us-east-1_hidden",
                        "AppClientId": "hidden",
                        "Region": "us-east-1"
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "socialProviders": [],
                        "usernameAttributes": [
                            "EMAIL"
                        ],
                        "signupAttributes": [
                            "EMAIL"
                        ],
                        "passwordProtectionSettings": {
                            "passwordPolicyMinLength": 8,
                            "passwordPolicyCharacters": []
                        },
                        "mfaConfiguration": "OFF",
                        "mfaTypes": [
                            "SMS"
                        ],
                        "verificationMechanisms": [
                            "EMAIL"
                        ]
                    }
                }
            }
        }
    },
    "api": {
            "plugins": {
                "awsAPIPlugin": {
                    "hidden": {
                        "endpointType": "REST",
                        "endpoint": "https://hidden-api.us-east-1.amazonaws.com/prod",
                        "region": "us-east-1",
                        "authorizationType": "AWS_IAM"
                  }
              }
          }
      },
      "storage": {
        "plugins": {
          "awsS3StoragePlugin": {
            "bucket": "hidden",
            "region": "us-east-1"
          }
        }
      }
}''';
Jordan-Nelson commented 1 year ago

@bjmcallister - Apologies for the delay in a response. There should be a stack trace logged immediately before that exception. Can you please share that?

Jordan-Nelson commented 1 year ago

@bjmcallister - If you are still facing this issue can you please provide and logs or stack traces leading up to this, or immediately following it? Thanks.

Jordan-Nelson commented 11 months ago

Closing issue as we have not heard back.