Flutter dio上传大文件时应用内存不足问题解决

Kill 'com.xxx.xxx' , uid 10930, oom_score_adj 0 to free 1843180kB rss, 1454600kB swap; reason: device is low on swap (28200kB < 209712kB) and thrashing (202%)

上传aws s3的时候,使用dio上传,小文件没有任何压力,但是在遇到大文件时,有些手机就会报上面的错误,并且app进程被kill

dio上传方式:


 void _uploadFile(Uint8List data,String url,SendCallback uplaodCallback) async {
    Dio dio = Dio();

    Map headers = {
      "Content-Type" : 'application/octet-stream',// "multipart/form-data",
      "x-amz-acl" : "public-read",
      "content-length":data.length,
    };

    var option = Options( contentType: 'application/octet-stream',headers: headers);//上传文件的content-type 表单

    var stream = Stream.fromIterable(data.map((e) => [e]));

    var response = await dio.putUri(Uri.tryParse(url), data: stream,options: option,onSendProgress:(int sent, 

你可能感兴趣的:(Flutter,flutter)