title: flutter send empty file to server
body: <p>Hi i'm trying to upload a file to a server via a flutter app but the file is always empty. 
  it was working fine and after that it stopped working.</p>
  
  <p>here is my code : </p>
  
  <pre><code>static uploadImageToServer(String image) async {
  File imageFile = new File(image);
  
  Map&lt;String, String&gt; headers = {
    'Content-Type': 'multipart/form-data',
    'Accept-Charset': 'UTF-8'
  };
  
  var stream = new http.ByteStream(DelegatingStream.typed(imageFile.openRead()));
  var length = await imageFile.length();
  print(imageFile.path);
  
  var uri = Uri.parse("http://planning.test/test_image");
  
  var request = new http.MultipartRequest("POST", uri);
  
  var multipartFile = new http.MultipartFile('File', stream, length,
      filename: "test_image_failure.jpg");
  
  request.headers.addAll(headers);
  request.fields['Destination'] = '/';
  
  print("**********");
  print(multipartFile.filename);
  print(uri);
  print(multipartFile.length);
  print("**********");
  
  request.files.add(multipartFile);
  
  print(request.contentLength);
  
  var response = await request.send();
  
  print(response.statusCode);
  
  response.stream.transform(utf8.decoder).listen((value) {
    print(value);
  });
  </code></pre>
  
  <p>}</p>
  
  <p>and with dio package </p>
  
  <pre><code>_dioUpload(String imageFile)async {
  var dio = Dio();
  var formData = FormData();
  formData.files.add(MapEntry(
    "File",
    await MultipartFile.fromFile(imageFile, filename: "xx.png"),
  ));
  
  print(formData.files.first.value.length);
  var response = await dio.post(
      "http://planning.test/test_image",
      data: formData,
    onSendProgress: (received, total) {
      if (total != -1) {
        print((received / total * 100).toStringAsFixed(0) + "%");
      }
    },
  );
  print(response);
  </code></pre>
  
  <p>}</p>
  
  <p>i don't understand what is happening everything look fine and the file exist.</p>
  
  <p>thx</p>