Answers for "flutter save json to file"

0

flutter save json to file

Future<ApiResponse<bool>> 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);
    });
  }
Posted by: Guest on July-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language