Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

File upload send progress goes too fast #2377

Open
matthew-carroll opened this issue Feb 8, 2025 · 3 comments
Open

File upload send progress goes too fast #2377

matthew-carroll opened this issue Feb 8, 2025 · 3 comments
Labels
h: need triage This issue needs to be categorized s: bug Something isn't working

Comments

@matthew-carroll
Copy link

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:

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.

@matthew-carroll matthew-carroll added h: need triage This issue needs to be categorized s: bug Something isn't working labels Feb 8, 2025
@AlexV525
Copy link
Member

AlexV525 commented Feb 8, 2025

Could you help to build a reproducible example with httpbun.com ?

@matthew-carroll
Copy link
Author

Are they gonna let me upload random files with 2 hours of audio data? In terms of the dio side, I've included exactly the relevant code.

Have you tried running a file upload with dio from a Mac CLI app? Or even a Mac Flutter app? Have you experienced the correct progress report using this API? It seems likely to me that this behavior is completely broken for everyone. If you haven't already, I would encourage you to try a file upload from a Mac and see what's reported on your end.

@AlexV525
Copy link
Member

AlexV525 commented Feb 8, 2025

Are they gonna let me upload random files with 2 hours of audio data? In terms of the dio side, I've included exactly the relevant code.

Oh, that was unsure for sure. :)

Have you tried running a file upload with dio from a Mac CLI app? Or even a Mac Flutter app?

No, I'm not near my Mac.

Have you experienced the correct progress report using this API?

Yes, the callback used to work IIRC. The library uses the HttpClient as the underlying implementation, if the problem does not come from it, it should be some recent changes that break the behavior. I just glanced at our tests and unfortunately, we seem not to have proper tests about it.

If you haven't already, I would encourage you to try a file upload from a Mac and see what's reported on your end.

What I wanted to say is that the bug reporter is the one nearest to the repro environment, which would make it easy to provide a reproducible example.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
h: need triage This issue needs to be categorized s: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants