【发布时间】:2021-08-09 05:58:19
【问题描述】:
我正在尝试使用 Amplify 将图像从 Flutter 上传到 AWS S3 存储桶。我使用这个Documentation 设置了 Flutter App,我无法将图像上传到 S3,
这是我的颤振代码
onPressed:
() async {
for(int i=1;i<images.length;i++)
{
final key = DateTime.now().toString();
File file = await getImageFileFromAssets(images[i]);
try {
print('## starting ##');
print('##${file.path} ##');
print('## upload starting ##');
final UploadFileResult result = await Amplify.Storage.uploadFile(local: file, key: key);// .uploadFile(local: file), key: key);
print('********Successfully uploaded image: ${result.key}');
} on StorageException catch (e) {
print('_________Error uploading image: $e');
}
}
},
这是我的输出
flutter: ## starting ##
flutter: ##/Users/prasathsivanathan/Library/Developer/CoreSimulator/Devices/A02325A9-A34C-4390-AF03-C0C2581CB062/data/Containers/Data/Application/34C934EF-84D3-4349-92A3-5754E21321D0/Library/Caches/IMG_0005.JPG ##
flutter: ## upload starting ##
[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 0
#0 List.[] (dart:core-patch/growable_array.dart:254:60)
#1 StorageCategory.uploadFile (package:amplify_flutter/categories/amplify_storage_category.dart:45:19)
#2 _MultipleImageDemoState.build.<anonymous closure> (package:gomicropro1/screens/DIY_Imagesection.dart:195:75)
<asynchronous suspension>
这里出了什么问题,
【问题讨论】:
标签: amazon-web-services flutter amazon-s3 aws-amplify