Skip to content

File upload send progress goes too fast with Dart+macOS #2377

@matthew-carroll

Description

@matthew-carroll

Package

dio

Version

5.8.0+1

Operating-System

MacOS

Adapter

Default Dio

Output of flutter doctor -v

FYI - I'm using dio directly in Dart on Mac, not within Flutter.

Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (8 weeks ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2

Dart Version

3.6.0

Steps to Reproduce

Here's a code sample that I'm using to upload an mp4 audio file:

  void test() {
    final client = dio.Dio();
    final response = await client.post(
      'https://myurl',
      options: dio.Options(
        headers: {
          "Authorization": "Bearer $authToken",
        },
      ),
      data: dio.FormData.fromMap({
        'file': dio.MultipartFile.fromFileSync(
          mediaFile.path,
          filename: basename(mediaFile.path),
        ),
      }),
      onSendProgress: (int sent, int total) {
        print('Send Progress (${(100 * sent / total).round()}): $sent/$total');
      },
      onReceiveProgress: (int sent, int total) {
        print('Receive Progress (${(100 * sent / total).round()}): $sent/$total');
      },
    );
  }

Expected Result

The "send progress" reflects the amount of data sent to the server, at the rate it's actually being sent.

Actual Result

The "send progress" reflects the data that's loaded into memory, or otherwise processed on the client side. The progress goes way too fast. I'm stuck sitting at 100% for about a minute as my large audio file uploads to the server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    h: need triageThis issue needs to be categorizeds: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions