Closed monish-siva closed 3 years ago
Hi @monishkumar-sivakumar can you provide the code you use to configure Amplify and to upload the video? Did you use Amplify CLI to setup your project?
Our example app has a working file upload function as well (here). I'm wondering if you would get the same error running that project as well.
Duplicated of https://github.com/aws-amplify/amplify-flutter/issues/169, which has been formatted.
I have experinced same issue with image uploader Code:
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
Hi @fjnoyp I used the amplify cli to configure amplify. here my code:
void configureAmplify() async { // First add plugins (Amplify native requirements) AmplifyStorageS3 storage = new AmplifyStorageS3(); AmplifyAuthCognito auth = new AmplifyAuthCognito(); amplify.addPlugin(authPlugins: [auth], storagePlugins: [storage]);
// Configure
await amplify.configure(amplifyconfig);
setState(() {
_isAmplifyConfigured = true;
});
}
void _upload() async { File local = await FilePicker.getFile(type: FileType.video); local.existsSync(); 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);
try {
UploadFileResult result = await Amplify.Storage.uploadFile(
key: key, local: local, options: options);
setState(() {
_uploadFileResult = result.key;
});
} catch (e) {
print(e.toString());
}
}
I have experinced same issue with image uploader Code:
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
File local = await getImageFileFromAssets(images.first); here for using getImageFileFromAssets(images.first) this, do i have to use any package or anything ?
Hey @rubana28 & @monishkumar-sivakumar
Sorry for the late reply.
I tested on iOS, and Android and I couldn't reproduce the issue
Please check our example app (here) for a working file upload function
Feel free to test using the latest build and let us know if you got any issues
Thanks Mo
Hey @rubana28 & @monishkumar-sivakumar
I am closing this issue for now as I didn't hear from you and I couldn't reproduce as per my comment above. We can reopen it if you are still facing the issue and when you provide details
Regards Mo
I setup amplify on my flutter project using the guides, but when I try to upload a video onto S3 from my Samsung Galaxy s9 I get this error message:
Here is my amplifyconfig file (I have taken out the keys and PoolID):