dio_smart_retry icon indicating copy to clipboard operation
dio_smart_retry copied to clipboard

Bad state: Can't finalize a finalized MultipartFile

Open aweiand opened this issue 1 year ago • 12 comments

Hi,

I'm using the latest packages:

dio: ^4.0.6
dio_smart_retry: ^1.3.2

When I post a file to the server and, it accepts only after first attemp, the error occours... here a simplified code:

    Dio dio = Dio(BaseOptions(
      baseUrl: ("https://$domain$base"),
    );

    dio.interceptors.add(
        RetryInterceptor(
          dio: dio,
          logPrint: print, // specify log function (optional)
          retries: 3, // retry count (optional)
          retryDelays: const [
            // set delays between retries (optional)
            Duration(seconds: 1), // wait 1 sec before first retry
            Duration(seconds: 2), // wait 2 sec before second retry
            Duration(seconds: 3), // wait 3 sec before third retry
          ],
        ),
      );

    final bytes = await cameraFile!.readAsBytes();
    final MultipartFile file = MultipartFile.fromBytes(bytes, filename: "teste");
    MapEntry<String, MultipartFile> a = MapEntry('teste', file);

    var options = FormData.fromMap({
      "bla": "bla",
    });

    options.files.add(a);

    var data = await dio.post("/post_test", data: options);

aweiand avatar Oct 17 '22 18:10 aweiand