Open Tyga76 opened 12 months ago
@Tyga76 sorry to hear you've ran into this issue.
If you're able to upgrade, have you tried a newer version of Amplify-Flutter? Do you still see the issue?
If so, can you also share the code you are using to upload the file?
@Tyga76 sorry to hear you've run into this issue.
If you're able to upgrade, have you tried a newer version of Amplify-Flutter? Do you still see the issue?
If so, can you also share the code you are using to upload the file?
Hi, sorry for the delay in response..my notifications aren't working.. `` I tried updating to the latest version for amplify and Storage plugins. Same issue, unfortunately.
my code to upload 👍
Future<void> uploadFile(FileModel file, String path) async {
// Select a file from the device
if (file.fileName.isBlank!) {
_logger.e('No file selected');
return;
}
// Upload file with its filename as the key
try {
final result = await Amplify.Storage.uploadFile(
localFile: AWSFile.fromData(file.fileData,
name: file.fileName, contentType: file.fileMIME),
key: '$path/${file.fileName}',
onProgress: (progress) {
_logger.e('Fraction completed: ${progress.fractionCompleted}');
},
options: StorageUploadFileOptions(
accessLevel: StorageAccessLevel.guest,
metadata: {'project': 'poc', 'contentType': file.fileMIME},
pluginOptions: const S3UploadFilePluginOptions(
getProperties: true,
),
),
).result;
keyName = result.uploadedItem.key;
_logger.e('Successfully uploaded file: ${result.uploadedItem.key}');
} on StorageException catch (e) {
_logger.e('Error uploading file: $e');
rethrow;
}
}
Hello @Tyga76 - Apologies for the delay. This appears to be a gap in the documentation for Amplify Flutter. Metadata is returned through http headers, and when using Web these headers have to be added to the CORS policy for your S3 bucket. You can following the docs here to see how to do that. The docs are for react, but in this case apply to flutter as well.
@Tyga76 I see you noted that your deployment method was the Amplify CLI. Can you confirm if the S3 bucket was created with the Amplify CLI? The CORS policy should be created for you if you use the Amplify CLI.
Description
I have successfully uploaded documents to my S3 bucket. I have added user-defined metadata that I can see on the object properties in the S3 console. However when I use Amplify.Storage.getProperties, it does not pull the metadata.
`
`
Categories
Steps to Reproduce
No response
Screenshots
No response
Platforms
Flutter Version
3.13.9
Amplify Flutter Version
1.0.4
Deployment Method
Amplify CLI
Schema
No response