-1

我正在尝试借助 http 请求将用户信息 ( imagePath, firstName, ) 上传到服务器。lastName

Future<UserModel> userSignUp({
    String firstName,
    String lastName,
    File imagePath,
  }) async {
    Map<String, dynamic> data = {
      "FNAME": firstName,
      "LNAME": lastName,
      "image": imagePath
    };
    var response = await _helper.post(
      Services.userSignUp,
      isSecure: false,
      headers: {
        "Content-Type": "application/json",
      },
      body: json.encode(data),
    );
    return UserModel.fromJson(response);
  }
4

1 回答 1

0

我相信您正在寻找一个MultipartRequest,这通常是在将图像或文件上传到服务器时需要的。

我假设您使用的是http 包,所以我认为您可以在 MultipartRequest 文档中找到有关如何执行此类请求的示例。

于 2020-06-12T13:29:00.857 回答