uploadFiles method

Future<StreamedResponse> uploadFiles(
  1. List<File> files,
  2. String folderPath
)

Implementation

Future<http.StreamedResponse> uploadFiles(List<File> files, String folderPath) async {
  var uri = Uri.parse('$apiHost/v1/filehandling/upload?folder=$folderPath');
  var request = http.MultipartRequest('POST', uri);
  request.headers['pkey'] = '3fd9d45242a947a43fdb0199bb383c40';
  for (var file in files) {
    var stream = http.ByteStream(file.openRead());
    var length = await file.length();
    var multipartFile = http.MultipartFile(
      'files',
      stream,
      length,
      filename: basename(file.path),
    );
    request.files.add(multipartFile);
  }
  var response = await request.send();
  return response;
}