uploadFiles method

Future<List<File>> uploadFiles({
  1. List<String>? filePaths,
  2. List<Uint8List>? filesBytes,
  3. List<String>? filenames,
  4. String uploadUrl = "/multi-upload-file",
})

Uploads multiple files.

On web, provide filesBytes and optional filenames. On native, you can provide either filePaths or filesBytes.

Implementation

Future<List<File>> uploadFiles({
  List<String>? filePaths,
  List<Uint8List>? filesBytes,
  List<String>? filenames,
  String uploadUrl = "/multi-upload-file",
}) async {
  try {
    final formData = await _buildMultiFilesFormData(
      filePaths: filePaths,
      filesBytes: filesBytes,
      filenames: filenames,
    );
    final response = await dio.post(uploadUrl, data: formData);
    return response.bodyAsList<File>();
  } catch (e) {
    rethrow;
  }
}