amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Error when uploading video using S3 Plugin

Open monish-siva opened this issue 6 years ago • 4 comments

I setup Amplify in my Flutter project using the guides. When I try to upload a vide to S3 from my Samsung Galaxy S9, I get this error message:

I/FilePickerUtils(32033): File loaded and cached at:/data/user/0/com.example.dotsmobile_homepage/cache/file_picker/Screen_Recording_20201024-184238_Instagram.mp4
I/FilePickerDelegate(32033): Absolute file path:/data/user/0/com.example.dotsmobile_homepage/cache/file_picker/Screen_Recording_20201024-184238_Instagram.mp4
I/flutter (32033): PlatformException(AmplifyException, UPLOAD_FILE_OPERATION_FAILED, {PLATFORM_EXCEPTIONS: {platform: Android, localizedErrorMessage: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference, recoverySuggestion: }})

Here is my amplifyconfig.dart file:

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:redacted",
              "Region":"us-east-1"
            }
          }
        },
        "CognitoUserPool":{
          "Default":{
            "PoolId":"us-east-1_redacted",
            "AppClientId":"redacted",
            "AppClientSecret":"redacted",
            "Region":"us-east-1"
          }
        },
        "Auth":{
          "Default":{
            "authenticationFlowType":"USER_SRP_AUTH"
          }
        },
        "S3TransferUtility":{
          "Default":{
            "Bucket":"dotsmobilehomepagea4700e40e7e54037ae778b7d14d94121456-dev",
            "Region":"us-east-1"
          }
        }
      }
    }
  },
  "storage":{
    "plugins":{
      "awsS3StoragePlugin":{
        "bucket":"dotsmobilehomepagea4700e40e7e54037ae778b7d14d94121456-dev",
        "region":"us-east-1",
        "defaultAccessLevel":"guest"
      }
    }
  }
}''';

monish-siva avatar Oct 30 '20 16:10 monish-siva

Are you using amplify-android or amplify-flutter? I assume you're using amplify-android since you opened this issue in this repo, but wanted to confirm. Also, which guides did you follow and what library versions are you using?

rjuliano avatar Oct 30 '20 17:10 rjuliano

I am using amplify flutter, my bad I will open up the issue in the other repo

monish-siva avatar Oct 30 '20 17:10 monish-siva

@monishkumar-sivakumar No need, @jpignata has re-assigned the issue for you.

jamesonwilliams avatar Oct 30 '20 18:10 jamesonwilliams

I have similar problem with amplify-flutter when attepmt to upload image file to s3 please se `below:

void _upload() async {
    try {
      print('In upload');
      File local = await getImageFileFromAssets(images.first);
      local.existsSync();
      print('Path: '+local.path);
      final key = 'key';
      Map<String, String> metadata = <String, String>{};
      metadata['category'] = 'category';
      metadata['desc'] = 'A photo';
      S3UploadFileOptions options = S3UploadFileOptions(
          accessLevel: StorageAccessLevel.guest, metadata: metadata);
      UploadFileResult result = await Amplify.Storage.uploadFile(
          key: key, local: local, options: options);
      setState(() {
        _uploadFileResult = result.key;
      });
    } catch (e) {
      print('UploadFile Err: ' + e.toString());
    }

and amplify config:

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": "id",
                            "Region": "eu-west-1"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "id",
                        "AppClientId": "id",
                        "AppClientSecret": "secret",
                        "Region": "eu-west-1"
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH"
                    }
                },
                "S3TransferUtility": {
                    "Default": {
                        "Bucket": "bucketname",
                        "Region": "eu-west-1"
                    }
                }
            }
        }
    },
    "storage": {
        "plugins": {
            "awsS3StoragePlugin": {
                "bucket": "bucket name",
                "region": "eu-west-1",
                "defaultAccessLevel": "guest"
            }
        }
    }
}''';```
I am receiving exactly same error message as @monishkumar-sivakumar

darmoz avatar Nov 03 '20 19:11 darmoz