通过在Android上运行的restApi(在iOS中不起作用)以抖动的方式上传图像

时间:2019-11-14 09:40:07

标签: rest http flutter multipart flutter-dependencies

您好,所有人都无法在服务器上上传图片,但在Android上工作正常,但在iOS中无法 状态码= android中的200 在iOS中状态代码= 403

static Upload(File image) async {
    String apiUrl = host + '/api/v1/profile/mobile/picture/new';
    var storage = SecureStorage();
    var authToken = await storage.getToken();
    Map<String, String> headers = {"Authorization": authToken};
    var postUri = Uri.parse(apiUrl);
    http.MultipartRequest request = new http.MultipartRequest("POST", postUri);
    request.headers.addAll(headers);
    request.files.add(
      await http.MultipartFile.fromPath('image', image.path),
    );
    request.send().then((response) {
      if (response.statusCode == 200) print("Uploaded!");
    });
  }

0 个答案:

没有答案