Open emondd4 opened 1 month ago
hi @emondd4 If you mean send list of files, I think there is a problem in your code. it depends on how your backend will receive the object but still you need to update your code
there are two ways to handle your case based on json structure
1- send files as objects if your json structure looks like this
{
"files" : {
"0": "file_data",
"1": "file_data",
"3": "file_data",
}
}
then you need to pass i to the field key like this
await http.MultipartFile.fromPath(
"files[i]", // pass i here
fileList[i]!.path,
contentType: MediaType(mimeTypeData[0], mimeTypeData[1]),
),
or 2- send files as list (preferred) if your json structure like this
{
"files" : [
"file_data_1",
"file_data_2",
"file_data_3",
]
}
then you need to update your code like this
await http.MultipartFile.fromPath(
"files[]", // don't pass anything in []
fileList[i]!.path,
contentType: MediaType(mimeTypeData[0], mimeTypeData[1]),
),
hope this help you
Future customMultipartWithFile (
String url,
String reservationId,
List titleList,
List<File?> fileList ) async {
}