每当我尝试将图像上传到我在颤振中创建的 s3 存储桶时,什么都没有发生。
final pickedFile = await picker.getImage(source: ImageSource.gallery);
try{
setState(() {
if (pickedFile != null) {
_image = File(pickedFile.path);
} else {
print('No image selected.');
}
});
print("here");
final key = new DateTime.now().toString();
print(key);
Map<String, String> metadata = <String, String>{};
metadata['name'] = 'filename';
metadata['desc'] = 'A test file';
S3UploadFileOptions options = S3UploadFileOptions(accessLevel: StorageAccessLevel.private, metadata: metadata);
try {
UploadFileResult result = await Amplify.Storage.uploadFile(
key: key,
local: _image,
options: options
);
print("Uploaded");
} on StorageException catch (e) {
print(e.message);
}
}catch (e){
Alert(
context: context,
type: AlertType.error,
desc: "Error Uploading File: " + e.toString());
}
}
我找到了关于主题https://github.com/aws-amplify/amplify-android/discussions/550的讨论,但是我没有 amplifyconfiguration.json 文件,我有 .dart 形式的文件。我的所有信息也都存在。我不确定为什么我无法上传到 s3。先感谢您!