📌  相关文章
📜  颤振将json保存到文件 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:01.982000             🧑  作者: Mango

代码示例1
Future> uploadfile(File file) async {

    var stream = new http.ByteStream(DelegatingStream(file.openRead()));
    var length = await file.length();
    var uri = Uri.parse("Enter your URL");
    var request = new http.MultipartRequest("POST", uri);
    var multipartFile = new http.MultipartFile('data', stream, length, filename: basename(file.path));
    request.files.add(multipartFile);
    await request.send().then((response) {
      response.stream.transform(utf8.decoder).listen((value) {
      file.delete();
        print(value);
      });

    }).catchError((e) {
      print(e);
    });
  }