Flutter:如何使用Dio上传文件

时间:2019-08-18 15:31:16

标签: flutter dart upload

我需要使用dart dio程序包在flutter的android应用中上传文件,但出现很多错误。有类似的案例代码供我参考的人吗?谢谢。以下是我遇到的错误。

E/flutter (10070): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: DioError [DioErrorType.DEFAULT]: HttpException: Content size exceeds specified contentLength. 177 bytes written while expected 171. [----dio-boundary-3374830655--
E/flutter (10070): ]
E/flutter (10070): #0      Dio._makeRequest (package:dio/src/dio.dart:799:16)
E/flutter (10070): <asynchronous suspension>
E/flutter (10070): #1      Dio._request.<anonymous closure>.<anonymous closure> (package:dio/src/dio.dart:711:22)
E/flutter (10070): #2      _rootRunUnary (dart:async/zone.dart:1132:38)
E/flutter (10070): #3      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (10070): #4      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
E/flutter (10070): #5      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
E/flutter (10070): #6      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
E/flutter (10070): #7      Future._complete (dart:async/future_impl.dart:473:7)
E/flutter (10070): #8      _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (10070): #9      _AsyncAwaitCompleter.complete.<anonymous closure> (dart:async-patch/async_patch.dart:33:20)
E/flutter (10070): #10     _rootRun (dart:async/zone.dart:1120:38)
E/flutter (10070): #11     _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (10070): #12     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (10070): #13     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
E/flutter (10070): #14     _rootRun (dart:async/zone.dart:1124:13)
E/flutter (10070): #15     _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (10070): #16     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter (10070): #17     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
E/flutter (10070): #18     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (10070): #19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (10070):

0 个答案:

没有答案