upload method
- List<
File> images
로컬 이미지 파일 여러장을 카카오스토리에 업로드
Implementation
Future<List<String>> upload(List<File> images) async {
return ApiFactory.handleApiError(() async {
List<MultipartFile> files = await Future.wait(images.map((image) async =>
await MultipartFile.fromFile(image.path,
filename: image.path.split("/").last)));
Map<String, MultipartFile> data = files.asMap().map((index, file) {
return MapEntry("${Constants.file}_${index + 1}", file);
});
final response = await _dio.post(Constants.scrapImagesPath,
data: FormData.fromMap(data));
var urls = response.data;
if (urls is List) return urls.map((url) => url as String).toList();
throw KakaoClientException("Response should be an array.");
});
}