uploadFiles method
Uploads multiple files to the specified upload URL.
Parameters:
filePaths
: A list of file paths to be uploaded.uploadUrl
: The URL to which the files will be uploaded. Defaults to/multi-upload-file
.
Returns:
Implementation
Future<List<File>> uploadFiles({
required List<String> filePaths,
String uploadUrl = '/multi-upload-file',
}) async {
FormData formData = FormData();
for (var filePath in filePaths) {
formData.files.add(
MapEntry(
'files',
await MultipartFile.fromFile(
filePath,
filename: path.basename(filePath),
),
),
);
}
return dio
.post(
uploadUrl,
data: formData,
)
.then((response) => response.bodyAsList<File>());
}