http icon indicating copy to clipboard operation
http copied to clipboard

MultipartRequest is not working correctly on Flutter WEB

Open ProfEPT-ricardo-sj opened this issue 2 years ago • 1 comments

Stream<List<int>> pseudoFileGenerator(int size) async* {
  List<int> list = [];
  for (int i = 0; i < size; i++) {
    list.add(i);
    if (i % 1024 == 0) {
      print('1kb');
      yield List.from(list);
      list = [];
    }
  }
  if (list.isEmpty == false) {
    yield List.from(list);
  }
}

//--------------------------------------------------------------------------------
sendMultpart(url) async{

      http.MultipartRequest multipartRequest = http.MultipartRequest('POST', url);
     
      http.MultipartFile multipartFile = http.MultipartFile(
        'campoField',
        pseudoFileGenerator(size),
        size,
        filename: '',
        contentType: mimeType,
      );

      multipartRequest.files.add(
        multipartFile,
      );

      await multipartRequest.send();

}

Expected results

when i call sendMultpart(...) on flutter for windows all code is done right: A chunk of bytes is load in memory and than sent to server, than another chunk of bytes is read and sent to server until done!

The problem is on WEB version of flutter. when I run this code on flutter web all the bytes is first load on memory and only after that the information is sent to server.

With this behavior my web code version need first load all file on memory to after that send to server. This is a very wrong behavior.

I expected that the web version work in same way of the windows version.

Actual results

The result of this is that I lose the chance to put my project on flutter in the company I work. Now we have to migrate to another tecnology.

ProfEPT-ricardo-sj avatar May 03 '23 12:05 ProfEPT-ricardo-sj

any updates on this?

Coinners avatar Jan 30 '24 19:01 Coinners