Can't Send large files through http multipart flutter web
When I am uploading a video of 500mb to the server, then it gives me error - RangeError: Array buffer allocation failed C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart 1069:7 _create1 C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart 1039:42 new C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/convert/byte_conversion.dart 86:19 add C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1586:10 runUnaryGuarded C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_impl.dart 339:11 [_sendData] C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_impl.dart 515:13 perform C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_impl.dart 620:10 handleNext C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_impl.dart 591:7 callback C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15
and not uplaoding video on the server.
Is there any solution to upload large videos upto 4 gb to the server from flutter web?
flutter - 3.3.9 http- 0.13.5 file_picker-5.2.2
cc @brianquinlan
Hi @aliaafreen,
Unfortunately the web implementation of Client does not support streaming request data.
If you are OK only supporting newer Chromium-based browsers then you could use package:fetch_client, which implements the Client interface.
Is it about the streaming? The log says the memory buffer has failed to allocate.
I'm assuming that this issue is being caused because the browser can't allocate enough memory to send the request so streaming the request would fix this.
@brianquinlan - should we think about re-implementing the web client in terms of the https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API API? (see also https://github.com/dart-lang/http/issues/595)
@devoncarew I think that package:fetch_client already does this and there is no reason for us to step in.
I could add stream as a feature in the HTTP implementation comparison table.
I didn't do that before because the answer is sometimes nuanced ;-)